Skip to content

Pre-release review fixes: utcp core - #22

Merged
leehack merged 3 commits into
mainfrom
fix/review-core
Nov 3, 2026
Merged

leehack merged 3 commits into
mainfrom
fix/review-core

Conversation

@leehack

@leehack leehack commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Fixes the pre-release audit findings in utcp: deep tool schemas and huge timeouts no longer crash parsing, and a GET body now behaves as in the reference SDKs. Follow-up to #4.

Fixes

  • Deep schemas. JsonSchema.fromJson walked nested schemas recursively, so a tool whose inputs nested about 10,000 deep raised StackOverflowError. That error got past discovery's on Exception catches and crashed UtcpClient.create. The walk is now iterative; a 50,000-deep schema parses again, as it did in 0.2.1.
  • Huge timeouts. optMilliseconds checked isFinite before multiplying by 1000, so "timeout": 1e306 (streamable_http) or retry_timeout (sse) threw UnsupportedError, and a finite value too large for a Duration (such as 1e16 ms) wrapped to a negative one on the VM. Both now throw a FormatException naming the field.
  • GET with a body. http sends the GET with its body, as Python (aiohttp) and TypeScript (axios) do; Elasticsearch _search relies on this. streamable_http still throws, as TypeScript does. A body argument that is null or absent means no body on every transport, so {'body': null} on a GET never throws. buildToolRequest takes a GetWithBody (send, reject, sendAsPost) in place of the unreleased postWithBody. A body is still never resent to another origin on a redirect.
  • Null const and default are dropped like every other null keyword, because Python writes them as null on every schema node. No conformance fixture changes, since the corpus already treats an explicit null as absent. The interop drivers need no new exclusion.
  • Tests that pin existing behavior. Each one fails when its check is mutated away:
    • a 401 from another origin after a redirect keeps the cached OAuth2 token (uri.origin == request.uri.origin);
    • a late 401 for an old token does not evict the refreshed one (_tokens[key]?.value == token);
    • expires_in: " 1 " sets a one-second cache lifetime, not the 3600 s default (string branch of _expiresIn).
  • CHANGELOG. The HTTP result changes (a YAML or untyped JSON body now comes back as a String; HttpResult.decode no longer parses YAML) and VariableLoader.toJson are marked Breaking. The GET-body bullet and the null-keyword bullet are corrected.

GET body decision

flowchart TD
    A[Tool call on a GET template] --> B{body_field argument<br/>null or absent?}
    B -- yes --> N[Send GET, no body]
    B -- no --> C{Transport}
    C -- http --> S[Send GET with body<br/>Python and TypeScript do]
    C -- streamable_http --> R[Throw UtcpException<br/>before any request, as TypeScript does]
    C -- sse --> P[Send POST with body]
Loading

Verification

  • dart format --output=none --set-exit-if-changed ., dart analyze --fatal-infos: clean
  • dart test (root, packages/utcp, packages/utcp_conformance) and dart test -p chrome test/unit: pass
  • tool/interop/run.sh with Python 3.12: exit 0

- Deeply nested tool schemas parse again: JsonSchema.fromJson no longer
  recurses, so a 50,000-deep `inputs` cannot overflow the stack and crash
  UtcpClient.create.
- A millisecond field that overflows to infinity (`"timeout": 1e306`)
  throws a FormatException naming the field instead of UnsupportedError.
- `http` sends a GET with its body, as the Python and TypeScript SDKs do;
  `streamable_http` still rejects it, as TypeScript does. A null body
  argument means no body everywhere. buildToolRequest takes a
  GetWithBody instead of postWithBody.
- Null `const` and `default` are dropped like every other null keyword.
- Tests pin the OAuth2 same-origin 401 guard, the stale-token eviction
  check and the string `expires_in` cache lifetime.
- CHANGELOG marks the HTTP result and VariableLoader.toJson changes as
  breaking.
@leehack
leehack merged commit e8c5d8f into main Nov 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant