Skip to content

fix(context): validate each find_teamspaces candidate's ticket custom type - #49

Open
antonisobkowicz-asana wants to merge 1 commit into
mainfrom
fix/find-teamspaces-schema-validation
Open

antonisobkowicz-asana wants to merge 1 commit into
mainfrom
fix/find-teamspaces-schema-validation

Conversation

@antonisobkowicz-asana

Copy link
Copy Markdown
Collaborator

Summary

Fixes CODE-1224: find_teamspaces returned candidates from Asana's typeahead endpoint with a blanket schema_validated: false on every response, regardless of whether a given candidate was actually configured as a Command Teamspace. An agent could select a plain project and only discover it was wrong on the next call, hitting schema_incompatible: "No ticket custom type found" — which is literally what happened to me twice in an earlier session on this same repo.

  • src/schema_discovery.ts: new exported hasResolvableTicketCustomType(), reusing the existing collectCustomTypes/resolveTicketCustomType logic (no duplicated logic) — one Asana call per candidate (customTypes.getCustomTypesWithHttpInfo({project: gid})), much cheaper than full schema discovery (skips custom-field-settings pagination and the per-Release project reads). Any CommandError from the check (incompatible, ambiguous, or otherwise) is treated as "not usable" rather than aborting the whole find_teamspaces call.
  • src/tools/context.ts: moved schema_validated from a top-level z.literal(false) onto each candidate as a real boolean, computed sequentially (one call per candidate, bounded by the existing deadline rather than bursting up to 20 concurrent requests) after the typeahead call.
  • src/tool_definitions/context.ts / README.md: updated the tool's advertised description to reflect the new, meaningful per-candidate signal instead of the old "not schema-validated" disclaimer.
  • Tests: new unit tests for hasResolvableTicketCustomType (true/false/ambiguous) in tests/schema_discovery.test.ts, a new tests/context.test.ts test proving mixed valid/invalid candidates are correctly distinguished (and that each gets its own customTypes lookup with the right project GID), plus updated existing tests/contract tests for the new output shape.

Breaking change, per AGENTS.md's "preserve the public MCP contract unless a task explicitly authorizes a breaking change" — find_teamspaces's output shape changes: the top-level schema_validated field is gone, replaced by a per-candidate one. Investigated non-validating and filter-based alternatives before choosing this approach; see the ticket/PR discussion for the tradeoffs (no native multi-project batching in the typed Asana SDK, so worst case is up to 20 sequential extra calls, bounded by the existing per-request deadline).

Test plan

  • npx tsc --noEmit
  • npm run lint
  • npm test — 387 passing
  • npm run build
  • npm run check (full gate)

🤖 Generated with Claude Code

… type

CODE-1224: find_teamspaces only fetched gid/name from Asana's typeahead
endpoint, so every candidate carried the same blanket
schema_validated: false regardless of whether it was an actual Command
Teamspace. An agent could pick an ordinary project and only discover
it was wrong on the next call, failing with schema_incompatible.

Move schema_validated onto each candidate and populate it with one
cheap customTypes lookup per candidate (not full schema discovery),
reusing the same resolveTicketCustomType check get_context relies on.
This is a breaking change to find_teamspaces' output shape.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant