Skip to content

testserver: fail on unexpanded shell/test variables in API requests#5378

Open
pietern wants to merge 1 commit into
mainfrom
testserver-unexpanded-var-guard
Open

testserver: fail on unexpanded shell/test variables in API requests#5378
pietern wants to merge 1 commit into
mainfrom
testserver-unexpanded-var-guard

Conversation

@pietern
Copy link
Copy Markdown
Contributor

@pietern pietern commented May 29, 2026

Changes

The test server now inspects each request's URL and body and fails the test if it finds an unexpanded uppercase variable reference (${FOO} or $FOO). Uppercase-only is deliberate: scripts inject test/env variables by that convention (UNIQUE_NAME, JOB_ID, …), while DABs interpolation is lowercase and namespaced (${resources.jobs.foo.id}), so it's ignored with no allowlist upkeep. Endpoints carrying variable-shaped content are exempt (file uploads and /telemetry-ext), and a global allowedDollarTokens escape hatch covers intentional cases.

One fixture that used $VAR-shaped placeholder values (resources/jobs/instance_pool_and_node_type) now uses plain literals; its assertion is unchanged.

Why

In #5376, a ${UNIQUE_NAME} left inside single quotes in an acceptance script was never expanded, so the literal test-pipeline-${UNIQUE_NAME} was sent to the API. The fake server accepted it, so the test passed locally and only failed intermittently on cloud — and it never appeared in output.txt. This guard turns that class of bug into a deterministic local failure on every PR. The check sits at the existing serve() chokepoint next to INJECT_ERROR, so it runs for every request regardless of engine or RecordRequests.

Tests

New table-driven unit tests for the matcher. Full acceptance suite passes in both direct and terraform modes with zero violations.

This pull request and its description were written by Isaac.

The test server now inspects each request's URL and body and fails the
test if it finds an unexpanded uppercase variable reference (${FOO} or
$FOO). Acceptance scripts inject test/env variables by that convention
(UNIQUE_NAME, JOB_ID, ...), while DABs interpolation is lowercase and
namespaced (${resources.jobs.foo.id}), so it is ignored with no allowlist
upkeep. Endpoints carrying variable-shaped content are exempt (file uploads
and /telemetry-ext), and a global allowedDollarTokens escape hatch covers
intentional cases.

This catches the class of bug fixed in #5376, where a ${UNIQUE_NAME} left
inside single quotes was sent to the API literally: locally the fake server
accepted it, so it only failed intermittently on cloud and never showed up
in output.txt.

One fixture that used $VAR-shaped placeholder values
(resources/jobs/instance_pool_and_node_type) now uses plain literals.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

Files: acceptance/bundle/resources/jobs/instance_pool_and_node_type/databricks.yml, acceptance/bundle/resources/jobs/instance_pool_and_node_type/output.txt
Suggested: @denik
Also eligible: @andrewnester, @shreyas-goenka, @janniklasrose, @anton-107, @lennartkats-db

General files (require maintainer)

Files: libs/testserver/server.go, libs/testserver/varguard.go, libs/testserver/varguard_test.go
Based on git history:

  • @denik -- recent work in libs/testserver/, acceptance/bundle/resources/jobs/instance_pool_and_node_type/

Any maintainer (@andrewnester, @anton-107, @denik, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

@pietern pietern temporarily deployed to test-trigger-is May 29, 2026 14:33 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 29, 2026 14:33 — with GitHub Actions Inactive
@pietern pietern requested a review from denik May 29, 2026 14:44
@pietern pietern enabled auto-merge May 29, 2026 14:54
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

Commit: 123301b

Run: 26643368861

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