-
Notifications
You must be signed in to change notification settings - Fork 54
Fix:Error message for invalid task ID #2345
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: develop
Are you sure you want to change the base?
Conversation
b55cbb0
to
0428080
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rahul-flex! This is going in the right direction but we should try to handle 404 errors more generally.
tidy3d/web/core/http_util.py
Outdated
raise TaskNotFoundError( | ||
"The requested task ID does not exist. Please verify your task ID." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much more general than not finding a task. Any request that returns a 404 status code will be caught here, so this should also raise a more generic exception. Maybe something like WebNotFoundError(WebError)
.
The error then needs to be handled properly by the caller. We can focus on tasks for now since that was the original intention. A good place to catch this is probably in tidy3d/web/core/task_core.py
61f4c3b
to
d46649b
Compare
tidy3d/web/core/exceptions.py
Outdated
class TaskNotFoundError(WebError): | ||
"""Raised when a requested task ID does not exist on the server.""" | ||
|
||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in principle i'm not opposed to having a fine grained error like this but on the other hand it seems like just raising a WebNotFoundError
should be fine. so maybe remove this one?
tidy3d/web/core/task_core.py
Outdated
except WebNotFoundError: | ||
raise TaskNotFoundError(f"The requested task ID '{task_id}' does not exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd probably do the following instead:
except WebNotFoundError as e:
td.log.error("error message")
raise e
03884b5
to
6b86fa0
Compare
Closes #2154 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rahul-flex looks good to go from my side, minus the little changelog clarification.
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- `fill` and `fill_structures` argument in `td.Simulation.plot_structures()` and `td.Simulation.plot()` respectively to disable fill and plot outlines of structures only. | |||
- New subpixel averaging option `ContourPathAveraging` applied to dielectric material boundaries. | |||
|
|||
### Changed | |||
- Error message for invalid task ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved error message and handling when attempting to load a non-existent task ID.
@QingengWei could you have a look? This addresses the discussion in #2154. The The old |
Previously, when web.load received a 404 response for an invalid or non-existent task ID, the client would return None and produce unhelpful error messages. This commit changes that behavior: it now raises a TaskNotFoundError with a clear, user-friendly explanation.
