Skip to content

fix(dart): resolve relative base URLs against the browser document - #3313

Open
dvd233 wants to merge 2 commits into
ag-ui-protocol:mainfrom
dvd233:fix/dart-relative-base-url-2649
Open

dvd233 wants to merge 2 commits into
ag-ui-protocol:mainfrom
dvd233:fix/dart-relative-base-url-2649

Conversation

@dvd233

@dvd233 dvd233 commented Nov 4, 2026 •

Copy link
Copy Markdown

Fixes #2649

Summary

  • Resolve browser-relative base URLs against document.baseURI, respecting Flutter Web’s base href and iframe documents. Root-relative paths retain origin-root semantics.
  • Preserve absolute HTTP(S) URL support and provide clear errors for relative URLs on native platforms.
  • Handle path joining and validate unsupported or unsafe URL forms. Add regression tests and document supported forms.
    Validation
  • Dart 3.13.7: 745 VM tests passed, 8 skipped; server-dependent integration tests excluded.
  • Browser test entry point compiled to JavaScript and Wasm. Thirteen compiled-Web smoke cases passed in Node with a mocked document; these are not real browser tests.
  • dart analyze: zero errors and no new diagnostics compared with the base; 55 existing warnings and 1,215 informational diagnostics remain.
  • git diff --check passed.
    Remaining verification

Real Chrome tests could not run because Chromium could not create its process socket in the validation environment. Browser compilation and mocked Node tests do not replace a real browser run. Dart 3.3 was not separately tested; PR CI results should be assessed independently.

Summary by CodeRabbit

  • New Features
    • Flutter Web clients can now use relative API base URLs, resolved against the current document’s base URL, including in iframes.
    • Native clients continue to require absolute HTTP(S) base URLs.
  • Bug Fixes
    • Improved URL validation to reject unsupported relative URL formats, credentials, and control characters.
  • Documentation
    • Clarified platform-specific base URL requirements and supported relative paths.

@dvd233
dvd233 requested a review from mattsp1290 as a code owner November 4, 2026 07:43
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Python Preview Packages

Version 0.0.0.dev1793778207 published to TestPyPI.

Warning: These packages are built from contributor code that may not yet have been vetted for correctness or security. Install at your own risk and do not use in production.

Install with uv

Add the TestPyPI index to your pyproject.toml:

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = true

Then install the packages you need:

# Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1793778207' --index testpypi

# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1793778207' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1793778207' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1793778207' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1793778207' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1793778207' --index testpypi

Install with pip

pip install \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  ag-ui-protocol==0.0.0.dev1793778207

Use --extra-index-url https://pypi.org/simple/ so pip can resolve
transitive dependencies (pydantic, fastapi, etc.) from real PyPI.


Commit: afa1963

@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ag-ui/a2a-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a-middleware@3313

@ag-ui/a2ui-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-middleware@3313

@ag-ui/event-throttle-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/event-throttle-middleware@3313

@ag-ui/mcp-apps-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-apps-middleware@3313

@ag-ui/mcp-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-middleware@3313

@ag-ui/a2a

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a@3313

@ag-ui/adk-js

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/adk-js@3313

@ag-ui/adk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/adk@3313

@ag-ui/ag2

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/ag2@3313

@ag-ui/agno

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/agno@3313

@ag-ui/antigravity

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/antigravity@3313

@ag-ui/aws-strands

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/aws-strands@3313

@ag-ui/claude-agent-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-agent-sdk@3313

@ag-ui/claude-managed-agents

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-managed-agents@3313

@ag-ui/crewai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/crewai@3313

@ag-ui/langchain

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langchain@3313

@ag-ui/langgraph

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langgraph@3313

@ag-ui/llamaindex

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/llamaindex@3313

@ag-ui/mastra

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mastra@3313

@ag-ui/pydantic-ai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/pydantic-ai@3313

@ag-ui/vercel-ai-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/vercel-ai-sdk@3313

@ag-ui/watsonx

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/watsonx@3313

@ag-ui/a2ui-toolkit

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-toolkit@3313

create-ag-ui-app

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/create-ag-ui-app@3313

@ag-ui/client

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/client@3313

@ag-ui/core

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/core@3313

@ag-ui/encoder

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/encoder@3313

@ag-ui/proto

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/proto@3313

commit: 3a7424e

@mattsp1290

Copy link
Copy Markdown
Collaborator

I’m Forg, an AI agent assisting Matt. I reviewed 3a7424e24c51d0bcff24ce95ac17594c297ade11 and found a browser-validation gap, not a demonstrated runtime bug.

The new browser suite is marked @TestOn('browser'), but the Dart workflow runs only dart test --exclude-tags requires-server. That defaults to the VM, so the green Dart job does not execute the tests for document.baseURI, iframe selection, base href changes, or relative-path resolution.

Independent validation with Dart 3.14.1:

  • Full VM suite: 745 passed, 8 skipped.
  • Focused base-URL/native tests: 21 passed.
  • The browser suite compiled to JavaScript, but Chrome failed before loading it with socket() failed: Operation not permitted, including on a retry outside the command sandbox. No browser assertions executed; compilation is not a browser pass.
  • Dart 3.3 minimum-version compatibility was not tested.

Please add an explicit Chrome step (with Chrome available), for example:

dart test -p chrome test/client/base_url_web_test.dart test/client/base_url_test.dart

That would make the existing useful browser coverage an actual CI gate for this browser-specific fix. I found no functional defect in the reviewed resolution/validation changes, but would want the real-browser run before treating this as verified.

@dvd233
dvd233 requested a review from a team as a code owner November 18, 2026 01:15
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Dart Base URL Resolution

Layer / File(s) Summary
Validation and base URL resolution
sdks/community/dart/lib/src/client/validators.dart, sdks/community/dart/lib/src/client/base_uri_stub.dart, sdks/community/dart/lib/src/client/base_uri_web.dart, sdks/community/dart/lib/src/client/base_url.dart, sdks/community/dart/test/client/base_url_test.dart, sdks/community/dart/test/client/base_url_native_test.dart
URL validation can allow relative references while checking control characters and credentials. On web, the resolver uses document.baseURI; native clients have no document base URI. Relative bases with queries or fragments are rejected, and native clients reject relative bases.
Client integration and behavior coverage
sdks/community/dart/lib/src/client/config.dart, sdks/community/dart/lib/src/client/client.dart, sdks/community/dart/test/client/base_url_web_test.dart, sdks/community/dart/README.md, .github/workflows/unit-dart-sdk.yml
AgUiClient.runAgent resolves the configured base URL and uses it for relative endpoints. Browser tests cover document and request URL resolution. The README documents URL requirements, and the workflow runs the base URL tests on Chrome.

Suggested reviewers: alemtuzlak

Change: Feature · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 5cb77

The Dart SDK now resolves relative base URLs against the browser document on web and still requires absolute HTTP(S) URLs on native platforms. No concrete defect was found in the validation, resolution or request construction. The browser tests were not run in the supplied evidence, but CI now runs them on Chrome. The change looks safe to merge.

Security architecture risk: Minimal · up to 5cb77

Relative URLs intentionally use the browser document’s base URL, while native clients still require absolute HTTP(S) URLs. The inspected changes preserve validation before requests and introduce no demonstrated material security or lifecycle regression. This does not establish that the broader client is safe.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — For clients configured with relative bases, control of the document base can select the destination for that client’s agent input and configured headers. Exposure follows the affected client’s payloads and header privileges; the inspected change introduces no server-side tenant or infrastructure authority.

Trust Boundaries and Controls

  • observed — Choosing a relative base delegates routing context to document.baseURI, including an absolute cross-origin base href. Scheme-relative configuration values are rejected, but same-origin confinement is not enforced. Explicit absolute base URLs bypass this ambient dependency.

Hardening Proposals

  • proposed — For credential-bearing clients, explicitly document that a cross-origin document base also selects the destination of configured headers. Recommend an absolute service URL or a deployment-level base-URI restriction when that delegation is not intended.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c80fa487-2d58-4bda-b478-c2532e653a3b
Commits

Reviewing files that changed from the base of the PR and between 08eae9d and 5cb77c9.

Files selected for processing: 11

  • .github/workflows/unit-dart-sdk.yml
  • sdks/community/dart/README.md
  • sdks/community/dart/lib/src/client/base_uri_stub.dart
  • sdks/community/dart/lib/src/client/base_uri_web.dart
  • sdks/community/dart/lib/src/client/base_url.dart
  • sdks/community/dart/lib/src/client/client.dart
  • sdks/community/dart/lib/src/client/config.dart
  • sdks/community/dart/lib/src/client/validators.dart
  • sdks/community/dart/test/client/base_url_native_test.dart
  • sdks/community/dart/test/client/base_url_test.dart
  • sdks/community/dart/test/client/base_url_web_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants