bugfix: http_interceptor fails if result is not of type dict (FXC-4739) #3133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to delete a
ModeSolverTaskas part of my automation scripts. However, deletion failed with the following error message:The last line (l198) triggering the error incorrectly assumes that result is an iterable. My suggested fix only checks for the existence of the "data" key if result is of type dict, otherwise simply returns result.
Note
Fixes response handling in
http_interceptorto avoid assuming JSON is always a dict.result["data"]whenresultis adict; otherwise returns the parsed JSON as-isWritten by Cursor Bugbot for commit b2a6047. This will update automatically on new commits. Configure here.
Greptile Summary
Fixed a
TypeErrorinhttp_interceptorthat occurred when API responses returned non-dict types (e.g., boolean values from DELETE operations). The fix adds anisinstance(result, dict)check before attempting dictionary operations like membership testing and key access.isinstance()before checking for 'data' key in responseTypeError: argument of type 'bool' is not iterablewhen DELETE endpoints return boolean success valuesConfidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client as API Client participant HTTP as http_interceptor participant API as Tidy3D API Client->>HTTP: http.delete(endpoint) HTTP->>API: DELETE request API-->>HTTP: 200 OK + JSON response alt Response has text HTTP->>HTTP: Parse JSON alt Result is dict HTTP->>HTTP: Check for warning opt Warning exists HTTP->>HTTP: Log warning end alt Has "data" key HTTP-->>Client: Return result["data"] else No "data" key HTTP-->>Client: Return result (entire dict) end else Result is not dict (e.g., boolean) Note over HTTP: NEW: Skip dict operations HTTP-->>Client: Return result directly end else Response has no text HTTP-->>Client: Return None end