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/pulsar): handle missing/invalid schema objects #11945

Merged

Conversation

Alice-608
Copy link
Contributor

@Alice-608 Alice-608 commented Nov 25, 2024

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

@Alice-608
Copy link
Contributor Author

Alice-608 commented Nov 25, 2024

Fix schema parsing issue in Pulsar ingestion

Problem Description:
This PR addresses a bug in the PulsarSource ingestion where schema.get("data") could return None or invalid JSON, causing a JSONDecodeError. This error interrupts the ingestion process and prevents further data processing.

Fix Description:
The fix includes:

Added validation for schema.get("data") to ensure it is not None or empty before attempting JSON parsing.
Implemented exception handling to catch JSONDecodeError and log a warning instead of failing the ingestion process.
Set default schema attributes when the data is invalid or missing.
Modified Files:

datahub/metadata-ingestion/src/datahub/ingestion/source/pulsar.py: Added validation for schema data and exception handling for JSONDecodeError.

Fixes: #11945

Testing Done:
This fix was verified in a real application scenario. After modifying the source code, I re-ran the DataHub ingestion process with PulsarSource, which previously failed due to a JSONDecodeError. With this fix applied:

Schema data that is None or invalid no longer causes the ingestion process to fail.
Warnings were logged for problematic schemas, and the process continued success

Impact:
This change only affects the PulsarSource ingestion process. No impact on other ingestion sources or overall system functionality is expected.

@github-actions github-actions bot added ingestion PR or Issue related to the ingestion of metadata community-contribution PR or Issue raised by member(s) of DataHub Community labels Nov 25, 2024
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Nov 25, 2024
@jjoyce0510 jjoyce0510 added the merge-pending-ci A PR that has passed review and should be merged once CI is green. label Nov 26, 2024
Comment on lines 87 to 89
avro_schema = json.loads(schema_data)
except JSONDecodeError as e:
avro_schema = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should have better error reporting for this - we should emit a warning for this

That warning should be part of the source report (e.g. source.report.warning(...)). We never use print in our codebase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah,I have modified it once according to the prompt,tks

@hsheth2 hsheth2 removed merge-pending-ci A PR that has passed review and should be merged once CI is green. needs-review Label for PRs that need review from a maintainer. labels Nov 26, 2024
@datahub-cyborg datahub-cyborg bot added the pending-submitter-response Issue/request has been reviewed but requires a response from the submitter label Nov 26, 2024
Alice added 2 commits November 27, 2024 21:35
@Alice-608
Copy link
Contributor Author

yeah,I have modified it once according to the prompt

Alice added 2 commits November 29, 2024 00:19
@hsheth2 hsheth2 changed the title Fix schema parsing issue in Pulsar ingestion fix(ingest/pulsar): handle missing/invalid schema objects Nov 29, 2024
@hsheth2 hsheth2 removed the pending-submitter-response Issue/request has been reviewed but requires a response from the submitter label Nov 29, 2024
@datahub-cyborg datahub-cyborg bot added the merge-pending-ci A PR that has passed review and should be merged once CI is green. label Nov 29, 2024
@hsheth2 hsheth2 merged commit ca46c02 into datahub-project:master Dec 4, 2024
100 of 102 checks passed
@Alice-608 Alice-608 deleted the master-fix-schema-parsing-issue branch December 8, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution PR or Issue raised by member(s) of DataHub Community ingestion PR or Issue related to the ingestion of metadata merge-pending-ci A PR that has passed review and should be merged once CI is green.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants