Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest/mode): Handle 204 response and invalid json #12156

Merged
merged 9 commits into from
Dec 24, 2024

Conversation

asikowitz
Copy link
Collaborator

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Dec 17, 2024
@@ -142,8 +170,89 @@ def test_mode_ingest_failure(pytestconfig, tmp_path):
}
)
pipeline.run()
try:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this wasn't actually testing anything... raise_from_status wasn't raising exceptions (we were overriding the implementation on the response object...) so we wouldn't assert anything. Changed up this file a bit so this test is actually testing stuff

@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Dec 17, 2024
@@ -1470,6 +1473,8 @@ def get_request():
response = self.session.get(
url, timeout=self.config.api_options.timeout
)
if response.status_code == 204:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment here? what's special about 204s?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

204 indicates "No Content", I think mode might be returning empty string in this case which isn't valid json. I can add a comment

except JSONDecodeError as json_error:
raise HTTPError(
f"{json_error.__class__.__name__}: {json_error}"
) from json_error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems extremely janky

let's extract out an ModeRequestErrorTypes = (HTTPError, JSONDecodeError)

and then use that everywhere else in the code e.g.

try:
...
except ModeRequestErrorTypes as error:
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it's a bit sketch. I don't like having to change error handling in like 5 different spots though. What do you think about just catching all exceptions? Seems better in case there's a third one we're somehow missing -- in general it's never good to short circuit ingestion because of a failed request

Copy link
Collaborator

@hsheth2 hsheth2 Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea for extracting a standard ModeRequestErrorTypes tuple means that we can just reuse that tuple in all our error handling, and we can easily add to the tuple in just one spot

we could also go with catching all exceptions, but it doesn't feel super clean

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Dec 18, 2024
@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Dec 21, 2024
@datahub-cyborg datahub-cyborg bot added pending-submitter-merge and removed needs-review Label for PRs that need review from a maintainer. labels Dec 23, 2024
@asikowitz asikowitz merged commit f4b33b5 into datahub-project:master Dec 24, 2024
75 of 76 checks passed
@asikowitz asikowitz deleted the mode-json-error-handling branch December 24, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata pending-submitter-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants