Skip to content

ShapeParser rejects bracket parameters the API accepts (e.g. past_performance[top=10]) #60

Description

@makegov-mark

Problem

The Tango API supports bracket parameters on shape expansions — e.g. on entities, shape=uei,display_name,past_performance[top=10](summary,top_agencies) where [top=N] controls how many top agencies are aggregated (default 5, max 100). The server accepts and honors this syntax.

The SDK cannot request it. ShapeParser raises before the shape is even usable for response parsing:

tango.exceptions.ShapeParseError: Expected ',' or ')' but found '['
  File "tango/shapes/parser.py", line 310, in _parse_field_list

Verified live: the HTTP request itself succeeds with the bracketed shape (the server returns correct past_performance aggregates), but _parse_response_with_shapeself._shape_parser.parse(shape) dies on the [, so list_entities(shape="...past_performance[top=10](...)") raises after a successful API call. The bracket-less form past_performance(summary,top_agencies) works end to end with the server's top-5 default, which is the current workaround.

Ask

Teach ShapeParser._parse_field_list to consume an optional [key=value] segment after a field name (before the parenthesized subfield list), carrying it through to the request while treating the field as its bare name (past_performance) for schema validation and response parsing — the response key has no bracket.

Notes

  • The schema side needs no new fields: past_performance is already shape-valid on entities (validated since 1.4.0's overlay regeneration).
  • A conformance/coverage angle to consider: nothing in the vendored contract currently describes bracket parameters, so parser support probably lands with a unit-level parse/round-trip test rather than a contract-driven one.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions