Skip to content

fix: handle generated SDK input validation - #117

Draft
HarshMN2345 wants to merge 5 commits into
mainfrom
codex/mcp-query-strings
Draft

fix: handle generated SDK input validation#117
HarshMN2345 wants to merge 5 commits into
mainfrom
codex/mcp-query-strings

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Draft: blocked on publishing an appwrite-console release containing sdk-generator#1899 and sdk-for-console-python#10, then updating MCP's dependency requirement and lockfile to that real release. The lockfile still contains 0.6.0, which does not provide these guards. The new public-handler regression therefore fails with the currently locked dependency; this PR is not ready to merge.

Passing query objects where the SDK expects a list of strings previously raised can only concatenate str (not "dict") to str. The generated SDK now validates string-array parameters from their OpenAPI schemas before serialization and raises AppwriteException(type="sdk_input_validation") with code 0 and no response. MCP returns that readable error and treats this precise local validation contract as an expected caller failure. Server failures, untyped SDK errors, and response-parsing failures remain reportable.

The earlier query-specific MCP guard is removed. Tests call the public MCP handler with the real SDK, verify malformed inputs produce an error before HTTP and without a Sentry event, and retain the existing valid-query argument checks for Unicode, empty lists, null, and omission.

Fixes MCP-X.

Validation:

  • Python 3.12: all 263 unit tests pass using a temporary source overlay of the generated SDK changes. Installed dependencies and the lockfile were unchanged.
  • With locked appwrite-console==0.6.0, the new regression fails for all five malformed-input cases; all 262 other tests pass. The transport boundary is blocked, so this check sends no HTTP requests.
  • Classification and monitoring regressions verify raw and wrapped local validation errors are ignored, while 5xx errors, untyped failures, and Pydantic response errors remain visible.
  • Ruff, Black, Pyright, git diff --check, and the normal Docker build pass. CI unit tests remain dependency-blocked until the published SDK is pinned.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The PR is not safe to merge until a published SDK release containing the generated input guards is required and locked so the normal regression suite passes.

Fix All in Claude CodeFindings

  1. P1 Locked SDK Breaks Regression
Fix with agent prompt
### Issue 1
tests/unit/test_server.py:540-586
The new public-handler regression depends on SDK-side validation that is absent from the currently locked `appwrite-console==0.6.0`, so the normal test suite fails for every malformed-input case. Until the dependency requirement and lockfile select a published release containing these guards, removing the MCP guard leaves current installations exposed to the original serialization failure and this PR cannot pass CI.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Recognizes only response-less sdk_input_validation exceptions with code zero.
  • Suppresses that category from error monitoring while retaining actionable SDK response-validation failures.
  • Exercises malformed and valid query inputs through the public MCP tool handler.
  • Remains dependency-blocked because the lockfile still selects appwrite-console==0.6.0.

Reviews (4) · Last reviewed commit: "fix: classify generated SDK input valida..."

Comment thread tests/unit/test_server.py Outdated
Preserve both the required-argument regressions from #116 and the query validation regressions from #117.
@HarshMN2345 HarshMN2345 changed the title fix: validate query string lists before SDK execution fix: handle generated SDK input validation Sep 11, 2026
@HarshMN2345

Copy link
Copy Markdown
Member Author

@greptile-apps Please review the updated implementation at eabc50d. The query-specific MCP guard has been removed; schema-driven validation belongs to sdk-generator#1899 and sdk-for-console-python#10. MCP now recognizes only the explicit local SDK input-validation exception contract. The PR remains draft because the current lockfile still selects SDK 0.6.0; its new regression is dependency-blocked until a fixed SDK is published and pinned. The PR description records the passing 263-test run with the regenerated SDK source overlay and the failing locked-SDK baseline.

Comment thread tests/unit/test_server.py
Comment on lines +540 to +586
def test_call_tool_returns_sdk_input_validation_for_unencoded_queries(self):
client = build_introspection_client()
manager = register_services(client, profile=API_KEY_PROFILE)
server = build_mcp_server(build_operator(manager, client), transport="stdio")
entry = server.get_request_handler("tools/call")
self.assertIsNotNone(entry)

async def run_check():
ctx = Mock()
ctx.protocol_version = "2026-07-28"
ctx.meta = None
ctx.session.client_params = None
for queries in (
[{"method": "limit", "values": [1]}],
[
'{"method":"limit","values":[1]}',
{"method": "offset", "values": [1]},
],
{"method": "limit", "values": [1]},
'{"method":"limit","values":[1]}',
[1],
):
with self.subTest(queries=queries):
params = types.CallToolRequestParams(
name="appwrite_call_tool",
arguments={
"tool_name": "tables_db_list_rows",
"arguments": {
"database_id": "database-id",
"table_id": "table-id",
"queries": queries,
},
},
)
result = await entry.handler(ctx, params)

self.assertTrue(result.is_error)
self.assertIn("type=sdk_input_validation", result.content[0].text)
self.assertIn("queries", result.content[0].text)
self.assertIn("string", result.content[0].text)

with (
patch(
"requests.sessions.Session.request",
side_effect=AssertionError(
"Invalid inputs must not send HTTP requests"
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Locked SDK Breaks Regression

The new public-handler regression depends on SDK-side validation that is absent from the currently locked appwrite-console==0.6.0, so the normal test suite fails for every malformed-input case. Until the dependency requirement and lockfile select a published release containing these guards, removing the MCP guard leaves current installations exposed to the original serialization failure and this PR cannot pass CI.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/test_server.py
Line: 540-586

Comment:
**Locked SDK Breaks Regression**

The new public-handler regression depends on SDK-side validation that is absent from the currently locked `appwrite-console==0.6.0`, so the normal test suite fails for every malformed-input case. Until the dependency requirement and lockfile select a published release containing these guards, removing the MCP guard leaves current installations exposed to the original serialization failure and this PR cannot pass CI.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed; this is the explicit merge blocker recorded at the top of the PR description, and the PR remains draft. The required sequence is to land the schema-driven generator guards in appwrite/sdk-generator#1899, publish the generated SDK from appwrite/sdk-for-console-python#10, then update MCP's requirement and lockfile to that published version. The actual regenerated SDK passes all 263 MCP unit tests through a temporary source overlay, while locked 0.6.0 reproduces exactly this regression in local and GitHub CI. This thread remains unresolved until the real dependency update makes the normal suite pass; the regression will not be weakened or skipped.

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.

1 participant