Repository navigation
fix(gti-mcp): return API errors from create and update collection tools - #345
Merged
Merged
Conversation
create_collection and update_collection_attributes read data["data"] straight from the GTI response. When the API answers with an error payload (403 for an account without collection access, 404 for an unknown collection id), the tool fails with "Error executing tool ...: 'data'" and the API's message is lost. Return an error dict with that message instead, using the same data guard as get_collections_commonalities. Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
Use PEP 585 dict[str, str] return annotation on _api_error, fall back to error_info['code'] when message is absent, and switch mock server expectations to expect_oneshot_request.
dandye
approved these changes
Nov 11, 2026
dandye
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for catching and fixing this, @VISHNU0906!
Nice work checking isinstance(data.get("data"), dict) rather than restricting to status == 200 so 201 Created collection responses keep working, keeping _api_error private to the module, and testing the full MCP client session round-trips against pytest-httpserver for 403/404 responses, non-dict error bodies, and {"data": null}.
I pushed a small follow-up commit to align with #347 before merging:
- Updated
_api_error's return annotation fromtyping.Dict[str, str]todict[str, str](UP006). - Added a fallback to
error_info.get("code")in_api_errorwhenmessageis absent, with a matching test case. - Switched the new
pytest-httpserverexpectations toexpect_oneshot_requestso parameterized cases sharing a status code do not collide on the session-scoped server.
Thanks again for all of your recent gti-mcp fixes!
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
create_collectionandupdate_collection_attributesreturndata["data"]from the GTI response without checking it. When the API sends back an error instead (403 for an account that can't create collections, 404 for an unknown collection id), the tool fails withand the API's message never reaches the client.
This PR returns
{"error": "API Error: <message>"}in that case, using the samedataguard thatget_collections_commonalitiesgot in #335. The success path doesn't change.Testing: new tests call both tools through the MCP client session against the pytest-httpserver mock, with a 403/404 error body, an error body without a message, and
{"data": null}. All five cases fail on main with the'data'error above. The fullserver/gtisuite passes (77 tests).@dandye could you take a look when you have a moment?