Add error handling for missing or malformed legal_sections.json#659
Conversation
|
@aryantripathi130306-droid is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
viru0909-dev
left a comment
There was a problem hiding this comment.
Thanks for the contribution, @aryantripathi130306-droid!
The error handling fix for _load_legal_sections() is a solid improvement — wrapping it in try/except for FileNotFoundError and json.JSONDecodeError prevents the NLP service from crashing when the data file is missing or malformed. Good catch!
However, your branch was forked from an older version of main, which caused 25 merge conflicts across unrelated files. To avoid these conflicts, I've cherry-picked your fix onto a clean branch from the latest main and merged it with credit to you.
For future contributions, please make sure to rebase your branch on the latest main before opening a PR:
git fetch upstream main
git rebase upstream/main
Pull Request
Description
This PR adds proper error handling in
_load_legal_sections()for cases wherelegal_sections.jsonis missing or contains malformed JSON.Previously, the application raised generic Python exceptions without providing meaningful feedback.
Changes Made
FileNotFoundErrorjson.JSONDecodeErrorBefore
legal_sections.jsonwas missingAfter
Testing
Tested the following scenarios:
legal_sections.json