Fix for base URL config in templated requests#18432
Merged
deanhannigan merged 5 commits intomasterfrom Apr 1, 2026
Merged
Conversation
…rly override their base url with the base url specified in the parent datasource config. Added more test coverage and refactors some areas to make them more readable or improve the UX
Contributor
There was a problem hiding this comment.
4 issues found across 10 files
Confidence score: 3/5
- Template URL rebasing in
packages/server/src/threads/query.tsignores legacyrestTemplate, so some templated datasources may still hit stored spec URLs unexpectedly. - In
packages/builder/src/components/integration/APIEndpointViewer.svelte,validateQueryreceives only the base/path URL, so forbidden-binding checks for query parameters can be skipped. - Given multiple medium-severity validation and URL handling gaps, there’s some user-impacting risk, though not necessarily merge-blocking.
- Pay close attention to
packages/server/src/threads/query.tsandpackages/builder/src/components/integration/APIEndpointViewer.svelte- URL rebasing and validation behavior may be inconsistent.
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/server/src/threads/query.ts">
<violation number="1" location="packages/server/src/threads/query.ts:130">
P2: Template URL rebasing only checks `restTemplateId`, so legacy templated datasources with `restTemplate` are skipped and still execute against the stored spec URL.</violation>
</file>
<file name="packages/builder/src/components/integration/APIEndpointViewer.svelte">
<violation number="1" location="packages/builder/src/components/integration/APIEndpointViewer.svelte:194">
P2: defaultSpecServerUrl isn’t reset when switching datasources, so a new datasource without config.url/spec server URL can inherit the previous base URL.</violation>
<violation number="2" location="packages/builder/src/components/integration/APIEndpointViewer.svelte:615">
P2: Early return on empty requestUrl causes silent failure; validation/error notification is skipped when the template base URL is missing and path resolves to "".</violation>
<violation number="3" location="packages/builder/src/components/integration/APIEndpointViewer.svelte:619">
P2: `validateQuery` no longer sees query parameters because it only receives `requestUrl` (path/base). This skips forbidden-binding checks for query params. Pass the fully built URL instead so query params are validated too.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
packages/builder/src/components/integration/APIEndpointViewer.svelte
Outdated
Show resolved
Hide resolved
melohagan
approved these changes
Apr 1, 2026
Collaborator
melohagan
left a comment
There was a problem hiding this comment.
LGTM! Pulled down locally and can see the custom server url is respected.
Nice tests 🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for REST template queries executing against the spec's default server URL and ignoring the REST datasource base url, if it was configured. When saved, the query stored the server[0] value of the available servers on the spec and changing it would have no effect.
Summary by cubic
Fixes templated REST queries ignoring the datasource base URL by swapping the stored spec server with the resolved datasource
config.urlat runtime, and shows the resolved URL in the builder.applyBaseUrlis now in@budibase/shared-coreand used by both server and builder with improved HBS handling.Bug Fixes
config.urlduring execution; HBS inconfig.url(e.g. static variables) is resolved first and the swap happens before field enrichment.applyBaseUrlpreserves path/query/hash and HBS blocks, no-ops when hosts match, strips trailing slashes, handles relative paths, and falls back to the datasource base when the host is an unresolved HBS or the current URL is an origin/empty; used by the serverQueryRunnerand builder preview.effectiveUrl); template queries still storeservers[0]as a stable default. Custom queries are unchanged.Refactors
applyBaseUrlto@budibase/shared-coreand added tests (shared-core and server).APIEndpointViewer.svelteURL state (renamedbaseUrltodefaultSpecServerUrl), now displayeffectiveUrl, and ensure the selected endpoint stays in the dropdown even if not in the loaded list.applyBaseUrlcoverage; added targeted tests forconstructFullPath,convertPathVariables, andvalidateQuery.CustomEndpointInputnow uses the sharedapplyBaseUrl.Written for commit d2f3a75. Summary will update on new commits.