fix(context): validate each find_teamspaces candidate's ticket custom type - #49
Open
antonisobkowicz-asana wants to merge 1 commit into
Open
antonisobkowicz-asana wants to merge 1 commit into
antonisobkowicz-asana wants to merge 1 commit into
Conversation
… 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>
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.
Summary
Fixes CODE-1224:
find_teamspacesreturned candidates from Asana's typeahead endpoint with a blanketschema_validated: falseon 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, hittingschema_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 exportedhasResolvableTicketCustomType(), reusing the existingcollectCustomTypes/resolveTicketCustomTypelogic (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). AnyCommandErrorfrom the check (incompatible, ambiguous, or otherwise) is treated as "not usable" rather than aborting the wholefind_teamspacescall.src/tools/context.ts: movedschema_validatedfrom a top-levelz.literal(false)onto each candidate as a realboolean, 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.hasResolvableTicketCustomType(true/false/ambiguous) intests/schema_discovery.test.ts, a newtests/context.test.tstest proving mixed valid/invalid candidates are correctly distinguished (and that each gets its owncustomTypeslookup with the rightprojectGID), 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-levelschema_validatedfield 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 --noEmitnpm run lintnpm test— 387 passingnpm run buildnpm run check(full gate)🤖 Generated with Claude Code