Skip to content

Validate contract list sort fields#62

Closed
pranavpandey2511 wants to merge 1 commit into
mainfrom
fix-contract-list-sort-validation
Closed

Validate contract list sort fields#62
pranavpandey2511 wants to merge 1 commit into
mainfrom
fix-contract-list-sort-validation

Conversation

@pranavpandey2511
Copy link
Copy Markdown
Contributor

@pranavpandey2511 pranavpandey2511 commented May 9, 2026

User description

Summary

  • Add a get_contract_list built-in sort-field whitelist in the MCP schema and runtime validation.
  • Mark contract_id as filter-only so invalid sortFilters: contract_id fails locally instead of reaching the public API as sort=filter__contract_id.
  • Add focused tests for schema guidance, invalid contract_id sorting, and mixed built-in/metadata sort serialization.

Root Cause

The MCP tool accepted free-form sortFilters, so the model could request contract_id. The server converted that into filter__contract_id, which passes the public API parameter shape but is not a valid Elasticsearch sort field for ContractSearchObjectV2Elastic.

Validation

  • npm test passed: 20 tests
  • git diff --check passed

Generated description

Below is a concise technical summary of the changes proposed in this PR:
Enforce whitelist validation for get_contract_list built-in sort fields by extending its schema and runtime logic with ValidationError checks before translating requests to SpotDraft. Document contract_id as a filter-only field in the tool guidance so agents avoid unsupported sort params that previously reached the public API.

TopicDetails
Sort tests Exercise schema guidance and sort serialization expectations through new tests that cover invalid contract_id sorting and mixed built-in/metadata sorts.
Modified files (1)
  • test/get-contract-list.test.mjs
Latest Contributors(1)
UserCommitDate
pranavpandey2511@gmail...Validate contract list...May 09, 2026
Sort field validation Validate built-in sort inputs via get_contract_list schema patterns and runtime checks so only supported fields reach the SpotDraft API and contract_id remains filter-only.
Modified files (2)
  • src/tools/contracts/AGENTS.md
  • src/tools/contracts/get_contract_list.ts
Latest Contributors(2)
UserCommitDate
pranavpandey2511@gmail...Validate contract list...May 09, 2026
aditya-gupta-sdedocs: Add modular AGEN...April 21, 2026
This pull request is reviewed by Baz. Review like a pro on (Baz).

@sachin-spotdraft sachin-spotdraft added the size/m < 500 lines of changes label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m < 500 lines of changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants