ai icon indicating copy to clipboard operation
ai copied to clipboard

isUrlSupported lowercases case-sensitive URL paths before matching provider patterns

Open brennanbutler01 opened this issue 1 month ago • 4 comments

Description

A provider pattern that accepts an exact URL with uppercase path characters fails isUrlSupported. Native URL support can therefore be misclassified and the SDK can download a file that the provider could have consumed directly. The fixture tests URL matching only; it makes no request.

Reproduction

Save as repro.mjs in a new directory. This uses synthetic fixtures and mocked providers; no credentials or live API calls are needed.

npm init -y
npm install @ai-sdk/[email protected]
node repro.mjs
import assert from 'node:assert/strict';
const {isUrlSupported}=await import(process.env.UTILS_ENTRY??'@ai-sdk/provider-utils');
const url='https://assets.example/Images/Photo.PNG';
const pattern=/^https:\/\/assets\.example\/Images\/Photo\.PNG$/;
assert.equal(pattern.test(url),true);
const result=isUrlSupported({url,mediaType:'image/png',supportedUrls:{'image/*':[pattern]}});
console.log({url,result});assert.equal(result,true,'A supported case-sensitive URL must match without rewriting its path');

The regular expression matches the original URL, but isUrlSupported returns false on both release and upstream.

AI SDK Version

Node.js v26.7.0; @ai-sdk/[email protected] (latest relevant release checked) and locally built upstream 6c65131f106f0ffcf77d0a3b685f67cbc43ea74b.

Root cause and proposed fix

Source. The helper lowercases the entire URL before testing the provider regular expressions. URL paths and query values can be case-sensitive; media-type normalization does not justify rewriting those components.

Untested proposal: match provider patterns against the original URL. If host normalization is needed, normalize only the scheme and hostname. Cover mixed-case paths and query values, along with case-insensitive media types and existing global/sticky RegExp behavior.

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct.

brennanbutler01 avatar Oct 14 '26 04:10 brennanbutler01

Identify issue type

Identified as Bug
Confidence: High

Rationale

This is a concrete incorrect behavior in an existing SDK utility: URL normalization changes case-sensitive components and causes supported provider URLs to be misclassified.

Evidence

  • isUrlSupported returns false for a provider regex that matches the original mixed-case URL exactly.
  • The helper reportedly lowercases the entire URL before matching, altering case-sensitive path and query components.
  • The issue includes a credential-free reproduction and confirms the failure on both the released package and an upstream build.

ai-sdk-factory[bot] avatar Oct 14 '26 04:10 ai-sdk-factory[bot]

I'll take this — small PR today, match patterns against the original URL (no full-URL lowercase).

maxiaochaos avatar Oct 14 '26 06:10 maxiaochaos

:rocket: Published in:

Package Version
ai 7.0.141 github npm
@ai-sdk/alibaba 2.0.67 github npm
@ai-sdk/amazon-bedrock 5.0.116 github npm
@ai-sdk/angular 3.0.141 github npm
@ai-sdk/anthropic 4.0.80 github npm
@ai-sdk/anthropic-aws 2.0.73 github npm
@ai-sdk/assemblyai 3.0.60 github npm
@ai-sdk/azure 4.0.102 github npm
@ai-sdk/baseten 2.1.47 github npm
@ai-sdk/black-forest-labs 2.0.61 github npm
@ai-sdk/bytedance 2.0.63 github npm
@ai-sdk/cartesia 3.0.55 github npm
@ai-sdk/cerebras 3.0.69 github npm
@ai-sdk/code-mode 1.0.98 github npm
@ai-sdk/cohere 4.0.61 github npm
@ai-sdk/deepgram 3.1.31 github npm
@ai-sdk/deepinfra 3.0.69 github npm
@ai-sdk/deepseek 3.0.65 github npm
@ai-sdk/devtools 1.0.44 github npm
@ai-sdk/elevenlabs 3.0.61 github npm
@ai-sdk/fal 3.0.61 github npm
@ai-sdk/fireworks 3.0.72 github npm
@ai-sdk/fish-audio 3.0.38 github npm
@ai-sdk/gateway 4.0.114 github npm
@ai-sdk/gladia 3.0.60 github npm
@ai-sdk/gmicloud 3.0.40 github npm
@ai-sdk/google 4.0.96 github npm
@ai-sdk/google-vertex 5.0.112 github npm
@ai-sdk/groq 4.0.61 github npm
@ai-sdk/harness 1.0.152 github npm
@ai-sdk/harness-acp 1.0.91 github npm
@ai-sdk/harness-claude-code 1.0.156 github npm
@ai-sdk/harness-cline 1.0.79 github npm
@ai-sdk/harness-codex 1.0.154 github npm
@ai-sdk/harness-cursor 1.0.66 github npm
@ai-sdk/harness-deepagents 1.0.152 github npm
@ai-sdk/harness-fx 1.0.66 github npm
@ai-sdk/harness-github-copilot 1.0.48 github npm
@ai-sdk/harness-grok-build 1.0.90 github npm
@ai-sdk/harness-opencode 1.0.154 github npm
@ai-sdk/harness-pi 1.0.154 github npm
@ai-sdk/heygen 3.0.2 github npm
@ai-sdk/huggingface 2.0.69 github npm
@ai-sdk/hume 3.0.60 github npm
@ai-sdk/klingai 4.0.62 github npm
@ai-sdk/langchain 3.0.141 github npm
@ai-sdk/llamaindex 3.0.141 github npm
@ai-sdk/luma 3.0.61 github npm
@ai-sdk/mcp 2.0.75 github npm
@ai-sdk/minimax 3.0.57 github npm
@ai-sdk/mistral 4.0.64 github npm
@ai-sdk/moonshotai 3.0.69 github npm
@ai-sdk/open-responses 2.0.65 github npm
@ai-sdk/openai 4.0.94 github npm
@ai-sdk/openai-compatible 3.0.69 github npm
@ai-sdk/otel 1.0.141 github npm
@ai-sdk/perplexity 5.0.12 github npm
@ai-sdk/policy-opa 1.0.141 github npm
@ai-sdk/prodia 2.0.61 github npm
@ai-sdk/provider-utils 5.0.60 github npm
@ai-sdk/quiverai 2.0.61 github npm
@ai-sdk/react 4.0.144 github npm
@ai-sdk/replicate 3.0.61 github npm
@ai-sdk/revai 3.0.60 github npm
@ai-sdk/rsc 3.0.141 github npm
@ai-sdk/sandbox-just-bash 1.0.152 github npm
@ai-sdk/sandbox-vercel 1.0.152 github npm
@ai-sdk/svelte 5.0.141 github npm
@ai-sdk/togetherai 3.0.70 github npm
@ai-sdk/topaz 3.0.7 github npm
@ai-sdk/tui 1.0.142 github npm
@ai-sdk/typesafe-ai 3.0.19 github npm
@ai-sdk/valibot 3.0.60 github npm
@ai-sdk/voyage 2.0.60 github npm
@ai-sdk/vue 4.0.141 github npm
@ai-sdk/workflow 2.0.73 github npm
@ai-sdk/workflow-harness 1.0.152 github npm
@ai-sdk/xai 5.0.22 github npm
@ai-sdk/zai 3.0.31 github npm

github-actions[bot] avatar Oct 15 '26 02:10 github-actions[bot]

Identify bug discovery

Discovery source: discovery:audit (medium confidence).

The report appears to originate from inspection of the SDK utility and targeted fixture testing rather than a failure in a real application. Although the author does not explicitly state their discovery method, the source-level diagnosis and deliberately synthetic reproduction support an audit origin at medium confidence.

  • The author identifies the exact implementation flaw: isUrlSupported lowercases the entire URL before applying provider regular expressions.
  • The reproduction uses synthetic URLs and mocked providers, with no credentials or live API calls.
  • The description explicitly says the fixture tests URL matching only and makes no request.
  • The author tested both the released package and a locally built upstream commit and linked directly to the relevant source file.
  • No production application, user traffic, or real provider failure is described.

ai-sdk-factory[bot] avatar Oct 19 '26 19:10 ai-sdk-factory[bot]