Skip to content

Commit 0aa2edb

Browse files
Prioritize internal-whitespace baseURL validation
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 2644de5 commit 0aa2edb

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

.changeset/curly-radios-visit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Add a new `@trigger.dev/ai` package with:
1010
- reconnect-aware stream handling on top of Trigger.dev Realtime Streams v2
1111
- strict `baseURL` normalization/validation (trimming, path-safe slash handling, absolute `http(s)` URLs only, no query/hash/credentials)
1212
- rejection of internal whitespace characters in normalized `baseURL` values
13-
- deterministic baseURL validation error ordering for multi-issue inputs (protocol → query/hash → credentials)
13+
- deterministic baseURL validation error ordering for multi-issue inputs (internal whitespace → protocol → query/hash → credentials)
1414
- explicit default `baseURL` behavior (`https://api.trigger.dev`) and case-insensitive `HTTP(S)` protocol acceptance

docs/tasks/streams.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,13 @@ Validation errors use these exact messages:
683683
- `baseURL must not include username or password credentials`
684684

685685
When multiple issues are present, validation order is deterministic:
686-
protocol → query/hash → credentials.
686+
internal whitespace → protocol → query/hash → credentials.
687687

688688
Examples of ordering:
689689

690690
- `ftp://example.com?x=1``baseURL must use http or https protocol`
691691
- `https://user:pass@example.com?x=1``baseURL must not include query parameters or hash fragments`
692+
- `ftp://user:pass@example.com/in valid?x=1``baseURL must not contain internal whitespace characters`
692693

693694
For richer TypeScript ergonomics in app code, `@trigger.dev/ai` also exports:
694695

packages/ai/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
- Added explicit validation that `baseURL` excludes internal whitespace characters.
3030
- Documented that `HTTP://` and `HTTPS://` are accepted (case-insensitive protocol matching).
3131
- Added deterministic validation ordering for multi-issue baseURL values
32-
(protocol → query/hash → credentials).
32+
(internal whitespace → protocol → query/hash → credentials).
3333
- Documented explicit default `baseURL` value (`https://api.trigger.dev`) when omitted.

packages/ai/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,13 @@ Validation errors use these exact messages:
190190
- `baseURL must not include username or password credentials`
191191

192192
When multiple issues are present, validation order is deterministic:
193-
protocol → query/hash → credentials.
193+
internal whitespace → protocol → query/hash → credentials.
194194

195195
Examples of ordering:
196196

197197
- `ftp://example.com?x=1``baseURL must use http or https protocol`
198198
- `https://user:pass@example.com?x=1``baseURL must not include query parameters or hash fragments`
199+
- `ftp://user:pass@example.com/in valid?x=1``baseURL must not contain internal whitespace characters`
199200

200201
## `ai.tool(...)` example
201202

packages/ai/src/chatTransport.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,17 @@ describe("TriggerChatTransport", function () {
874874
}).toThrowError("baseURL must use http or https protocol");
875875
});
876876

877+
it("prioritizes internal-whitespace validation over protocol/query/hash/credential validation", function () {
878+
expect(function () {
879+
new TriggerChatTransport({
880+
task: "chat-task",
881+
accessToken: "pk_trigger",
882+
baseURL: "ftp://user:pass@example.com/in valid?query=1#fragment",
883+
stream: "chat-stream",
884+
});
885+
}).toThrowError("baseURL must not contain internal whitespace characters");
886+
});
887+
877888
it("prioritizes query/hash validation over credential validation", function () {
878889
expect(function () {
879890
new TriggerChatTransport({
@@ -3404,6 +3415,17 @@ describe("TriggerChatTransport", function () {
34043415
}).toThrowError("baseURL must use http or https protocol");
34053416
});
34063417

3418+
it("prioritizes internal-whitespace validation over protocol/query/hash/credential validation in factory", function () {
3419+
expect(function () {
3420+
createTriggerChatTransport({
3421+
task: "chat-task",
3422+
accessToken: "pk_trigger",
3423+
baseURL: "ftp://user:pass@example.com/in valid?query=1#fragment",
3424+
stream: "chat-stream",
3425+
});
3426+
}).toThrowError("baseURL must not contain internal whitespace characters");
3427+
});
3428+
34073429
it("prioritizes query/hash validation over credential validation in factory", function () {
34083430
expect(function () {
34093431
createTriggerChatTransport({

0 commit comments

Comments
 (0)