Fix harness_list output validation for PR activity#248
Conversation
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
|
|
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
There was a problem hiding this comment.
1 finding.
- Medium —
harness_listis fixing list-shape drift in the wrong layer. The new normalization insrc/tools/harness-list.tsmakes this tool return{ items, total }for bare-array / raw-envelope responses, but the affected resource definitions still advertiseresponseExtractor: passthroughinstead of using the registry extractor layer that already owns list normalization. That splits the contract across layers, duplicates backend-shape knowledge, and leaves otherRegistry.dispatch(..., "list")consumers inconsistent. The cleaner fix is to normalizepr_activity(and any sibling raw-array PR list endpoints) in the resource extractor layer, reusing the existing extractor helpers there.
Sent by Cursor Automation: Sunil On Demand Architecture Review
| input.template_list_type = "All"; | ||
| } | ||
| const result = await registry.dispatch(client, resourceType, "list", input); | ||
| const result = normalizeListResult(await registry.dispatch(client, resourceType, "list", input)); |
There was a problem hiding this comment.
Medium: this is patching the symptom in the generic tool instead of fixing the list contract where the repo already normalizes response shapes.
If pr_activity is a bare-array list, the canonical fix is to switch that resource off responseExtractor: passthrough and use a registry extractor (v1ListExtract() or a dedicated extractor) in src/registry/toolsets/pull-requests.ts. Doing it here duplicates list-envelope knowledge the registry already owns, and Registry.dispatch(..., "list") still returns raw arrays to other shared consumers that assume { items, total } (for example harness_search). That’s exactly the kind of boundary drift CLAUDE.md/AGENTS.md ask us to avoid.


Description
Fixes
harness_list(resource_type="pr_activity")output validation when the Harness Code activities API returns a bare array. The list tool now normalizes bare arrays and common list-array wrapper keys into{ items, total }before compacting and formatting, ensuring MCPstructuredContentis present for the declared output schema.Type of Change
Checklist
Verification:
pnpm test tests/tools/tool-handlers.test.tspnpm typecheckpnpm buildpnpm test