Skip to content

fix(ai-parasail): require clean api base urls#815

Open
aiirvizionz wants to merge 2 commits into
profullstack:masterfrom
aiirvizionz:clientkit/parasail-clean-base-url
Open

fix(ai-parasail): require clean api base urls#815
aiirvizionz wants to merge 2 commits into
profullstack:masterfrom
aiirvizionz:clientkit/parasail-clean-base-url

Conversation

@aiirvizionz

Copy link
Copy Markdown
Contributor

Summary

  • normalize the Parasail API base URL before building the chat completions endpoint
  • strip trailing slashes so custom /v1/ bases do not produce double-slash request paths
  • reject base URLs containing credentials, query strings, or fragments before any network call
  • add focused generation tests around request construction and malformed base URLs

Why

The adapter previously concatenated config.baseUrl directly with /chat/completions. A custom base URL ending in / created a //chat/completions path, and URLs with credentials/query/hash could create surprising request targets. This keeps Parasail endpoint construction explicit and predictable.

Validation

  • vitest run packages/ai/parasail/src/index.test.ts (4 passed)
  • tsc -p packages/ai/parasail/tsconfig.json --noEmit
  • git diff --check

Copilot AI review requested due to automatic review settings July 23, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Parasail AI adapter’s request construction by normalizing and validating the configured API base URL before building the /chat/completions endpoint, preventing surprising request targets and double-slash paths.

Changes:

  • Normalize config.baseUrl (strip trailing slashes) before constructing the chat completions URL.
  • Reject base URLs containing credentials, query strings, or fragments before any network call.
  • Add targeted Vitest coverage for URL normalization and malformed base URL rejection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/ai/parasail/src/index.ts Introduces cleanBaseUrl() and uses it to build a predictable /chat/completions request URL.
packages/ai/parasail/src/index.test.ts Adds focused tests verifying request URL construction and base URL validation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +83
function cleanBaseUrl(value: string): string {
const url = new URL(value);
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
throw new Error('Parasail baseUrl must use http or https');
}
if (url.username || url.password || url.search || url.hash) {
throw new Error('Parasail baseUrl must be a clean API base without credentials, query, or hash');
}
return url.toString().replace(/\/+$/, '');
}
Copilot AI review requested due to automatic review settings July 23, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants