Skip to content

Conversation

@aviau
Copy link
Member

@aviau aviau commented Sep 16, 2025

No description provided.

@aviau aviau force-pushed the aviau/api-domains branch 3 times, most recently from 95a0620 to a9c198a Compare September 16, 2025 22:24

api_domain = api_domain or _API_DOMAIN_DEFAULT
if api_domain not in _ALLOWED_API_DOMAINS:
raise Exception(

Choose a reason for hiding this comment

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

I would raise ValueError instead of a generic Exception

Copy link
Member Author

Choose a reason for hiding this comment

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

Does it matter? Is it an exception that will be caught?

Choose a reason for hiding this comment

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

It matters for the tests. The test actually catches a generic Exception and will fail to fail if the exception is raised by a coding error, whereas with a ValueError code errors can be caught. Our API users can also better understand that the exception was raised because of a value that was provided by them instead of being an error that we caused in our code.

Copy link
Member Author

@aviau aviau Sep 16, 2025

Choose a reason for hiding this comment

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

But the tests match the exact exception message:

with pytest.raises(Exception, match="Invalid API domain"):

Copy link
Member Author

Choose a reason for hiding this comment

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

I would argue that setting a specific exception type will increase our API surface? Meaning that our users might start writing code that handles this exception differently. Are we sure we want to support that? Are we willing to commit to it forever?

@aviau aviau force-pushed the aviau/api-domains branch 3 times, most recently from 24f92cb to 1ea6433 Compare September 16, 2025 22:35
@aviau aviau merged commit eaa0d13 into main Sep 16, 2025
5 checks passed
@aviau aviau deleted the aviau/api-domains branch November 19, 2025 23:20
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.

3 participants