Relationships
#2904 Extension content extractor truncates metadata when a string, comment or regex contains an unpaired brace
Opened by stack72 · 10/1/2026· Shipped 10/2/2026
Summary
src/domain/extensions/extension_content_extractor.ts finds block bodies with extractBalancedBraces, which counts every { and } in the source, including ones inside string literals, template literals, comments and regex literals. One unpaired brace in such a literal ends or extends a block early, so swamp extension push sends incomplete contentMetadata. The server accepts it because it validates, so the registry listing is silently wrong.
Reproduction
A model whose first method's execute contains any of:
log("{")orlog('}')// a lone }or/* { */const re = /\\{/;or/[{]/g
lists only the first method; every later method and the top-level resources are lost.
Seen in the wild
In swamp-extensions, model/aws/wellarchitected/extensions/models/agent_goal.ts and model/gcp/apigee/extensions/models/apiproducts_rateplans.ts have pattern strings containing \\$\\{. The extractor reports 0 of 9 and 10 of 23 global arguments for them.
Suggested fix
Skip string, template (with ${...} re-entering code), comment and regex literals while counting braces. swamp-club#2890 fixes the server fallback extractor this way, including a guard that keeps the regex heuristic linear on hostile input. Port the scanner (findClosingBrace / skipNonCode in lib/app/extract-extension-content.ts) and its tests.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.