Conversation
|
There was a problem hiding this comment.
All reported issues were addressed across 37 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 18 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Confidence score: 3/5
- In
packages/protocol/schemas.ts, theapiUrlrefine currently allows URLs with query strings/fragments, so later raw/v1concatenation can generate invalid gateway endpoints and cause request failures at runtime — tighten validation to service-origin URLs only (or normalize/sanitize before appending/v1).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/protocol/schemas.ts">
<violation number="1" location="packages/protocol/schemas.ts:1556">
P2: Some accepted `apiUrl` values still produce broken gateway endpoints, because query strings/fragments pass this refine and `/v1` is appended as raw text later. Suggest constraining `apiUrl` to a service-origin form (no query/hash) in this validator.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| .refine((value) => !new URL(value).pathname.replace(/\/+$/, "").endsWith("/v1"), { | ||
| message: "Stagehand apiUrl must be a service origin without /v1", | ||
| }) |
There was a problem hiding this comment.
P2: Some accepted apiUrl values still produce broken gateway endpoints, because query strings/fragments pass this refine and /v1 is appended as raw text later. Suggest constraining apiUrl to a service-origin form (no query/hash) in this validator.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/protocol/schemas.ts, line 1556:
<comment>Some accepted `apiUrl` values still produce broken gateway endpoints, because query strings/fragments pass this refine and `/v1` is appended as raw text later. Suggest constraining `apiUrl` to a service-origin form (no query/hash) in this validator.</comment>
<file context>
@@ -1551,10 +1551,16 @@ export const StagehandInitParamsSchema = z
- }),
+ apiUrl: z
+ .url()
+ .refine((value) => !new URL(value).pathname.replace(/\/+$/, "").endsWith("/v1"), {
+ message: "Stagehand apiUrl must be a service origin without /v1",
+ })
</file context>
| .refine((value) => !new URL(value).pathname.replace(/\/+$/, "").endsWith("/v1"), { | |
| message: "Stagehand apiUrl must be a service origin without /v1", | |
| }) | |
| .refine((value) => { | |
| const url = new URL(value); | |
| const pathname = url.pathname.replace(/\/+$/, ""); | |
| return !pathname.endsWith("/v1") && url.search === "" && url.hash === ""; | |
| }, { | |
| message: "Stagehand apiUrl must be a service origin without /v1, query params, or hash fragments", | |
| }) |
before
Endpoint routing relied on environment variables, and
STAGEHAND_API_URLwas not consumed by the SDK.after
Both endpoints are configured explicitly:
The same options are available in Python and Go, with production defaults.
test plan