Skip to content

fix: return 400/501 instead of 500 for invalid country codes#84

Merged
animator merged 5 commits into
foss42:mainfrom
aditya047-stack:#83
Jun 21, 2026
Merged

fix: return 400/501 instead of 500 for invalid country codes#84
animator merged 5 commits into
foss42:mainfrom
aditya047-stack:#83

Conversation

@aditya047-stack

Copy link
Copy Markdown
Contributor

Fixes #83

Changes

  • Add not_implemented_501() helper in models/responses.py
  • Fix /subdivisions to return 501 for unsupported countries
  • Fix /data, /flag, /name, /officialname to return 400 for invalid codes
  • Separate ValueError and NotImplementedError handling

##Before
Screenshot 2026-03-07 141003

Screenshot 2026-03-07 140938

##After
Screenshot 2026-03-07 140544

Screenshot 2026-03-07 140521

- Add not_implemented_501() helper in models/responses.py- Fix /subdivisions to return 501 for unsupported countries- Fix /data, /flag, /name, /officialname to return 400 for invalid codes- Separate ValueError and NotImplementedError handling
@animator

animator commented Mar 7, 2026

Copy link
Copy Markdown
Member

It should be data not found error instead of server side error.

@aditya047-stack

Copy link
Copy Markdown
Contributor Author

Thanks for addressing this issue and helping to solve it .i have updated the fix based on feedback — changed 400 to 404
for invalid country codes as it's a "data not found"
error rather than a bad request. Looking forward to such help again!

@animator animator merged commit 6bb1c48 into foss42:main Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid country code returns 500 instead of 400/501

2 participants