Skip to content

fix(appkit): report only the actually-missing env vars in resource errors#486

Merged
MarioCadenas merged 2 commits into
mainfrom
fix/resource-validation-error-only-missing
Jul 22, 2026
Merged

fix(appkit): report only the actually-missing env vars in resource errors#486
MarioCadenas merged 2 commits into
mainfrom
fix/resource-validation-error-only-missing

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

Problem

ResourceRegistry.formatMissingResources (and the dev-mode warning banner) printed every field's env var for a missing resource via Object.values(entry.fields).map((f) => f.env) — regardless of whether that var was already set, and including env-less discovery-only fields (which map to undefined and render as stray empty entries).

For a multi-field resource like Lakebase Postgres, a single unset variable produced a confusing message listing all seven fields plus empty slots:

Missing required resources:
  - postgres:Postgres [lakebase] (set , , , PGHOST, PGDATABASE, LAKEBASE_ENDPOINT, PGPORT, PGSSLMODE)

…even when only PGPORT was actually missing. The real problem was buried.

Fix

Add a private unsetEnvVars() helper that returns only the env vars that are actually unset/empty, skipping fields that declare no env — mirroring the exact resolution check already in validate(). Both formatMissingResources and formatDevWarningBanner now use it, so the error lists exactly what the caller must set:

Missing required resources:
  - postgres:Postgres [lakebase] (set PGPORT)

Tests

  • New: a partially-configured multi-field resource reports only the unset var, not the one already set.
  • New: env-less discovery-only fields never appear (no stray empty entries).
  • A mutation reverting the fix fails exactly these two tests.
  • Full resource-registry suite: 26/26 pass; appkit typecheck + biome clean.

Scope

This is a reporting fix only. Separately, fields with a static "value" default in the manifest (e.g. PGPORT: "5432") are still reported as missing because validate() reads only process.env and ignores the "value" fallback — a deeper bug left out of this PR.

Branched from main; independent of the graceful-shutdown work in #441.


This PR was created with GitHub MCP.

…rors

ResourceRegistry.formatMissingResources and formatDevWarningBanner printed
every field's env var for a missing resource via
Object.values(entry.fields).map(f => f.env) — including vars already set and
env-less discovery-only fields (which mapped to undefined, rendering as
stray empty entries like 'set , , , PGHOST, ...'). With a multi-field
resource such as Lakebase Postgres, a single unset var (e.g. PGPORT)
produced a confusing message listing all seven fields.

Add a private unsetEnvVars() helper that returns only the env vars that are
actually unset/empty, skipping fields with no env, mirroring validate()'s
own resolution check. Both formatters now list exactly what the caller must
set. Add tests: only-unset-reported, and env-less fields omitted (a mutation
reverting the fix fails both).

Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
@MarioCadenas
MarioCadenas requested a review from a team as a code owner July 22, 2026 09:34
@MarioCadenas
MarioCadenas requested a review from pkosiec July 22, 2026 09:34
@github-actions

Copy link
Copy Markdown
Contributor

🔬  Run evals on this PR  ·  Go to Evals Monitor →

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 708 KB (+5.4 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 732 KB (+3.9 KB) 256 KB (+1.3 KB)
Type declarations 276 KB (+1.9 KB) 94 KB (+642 B)
Source maps 1.4 MB (+12 KB) 478 KB (+3.9 KB)
Other 11 KB 3.7 KB
Total 2.4 MB (+17 KB) 832 KB (+5.9 KB)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 79 KB (+148 B) 2.5 KB 81 KB (+148 B) external 259 KB (+274 B)
./beta 39 KB (+457 B) 231 B (+1 B) 40 KB (+458 B) external 118 KB (+1.2 KB)
./type-generator 19 KB 0 B 19 KB external 54 KB

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 75 KB
. utils.js initial 4.0 KB
. remote-tunnel-manager.js lazy 2.5 KB
./beta beta.js initial 30 KB
./beta databricks.js initial 5.8 KB
./beta service-context.js initial 3.2 KB
./beta client-options.js initial 220 B
./beta databricks.js lazy 128 B
./beta index.js lazy 103 B
./type-generator index.js initial 19 KB

@databricks/appkit-ui

npm tarball (packed): 295 KB — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 350 KB 116 KB
Type declarations 201 KB 72 KB
Source maps 669 KB 218 KB
CSS 16 KB 3.3 KB
Total 1.2 MB 410 KB
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
./js 4.3 KB 49 KB 54 KB 208 KB 12 KB
./js/beta 20 B 0 B 20 B 0 B 0 B
./react 428 KB 49 KB 476 KB 1.3 MB 163 KB
./react/beta 20 B 0 B 20 B 0 B 0 B

Chunks:

Entry Chunk Load Size (gz)
./js index.js initial 4.2 KB
./js chunk initial 120 B
./js apache-arrow lazy 49 KB
./js/beta beta.js initial 20 B
./react index.js initial 426 KB
./react tslib initial 2.1 KB
./react apache-arrow lazy 49 KB
./react/beta beta.js initial 20 B

…porting

The only-missing-env-var fix left three spots still using the old
Object.values(fields).map(f => f.env) pattern:

- validate() JSDoc @example printed every field's env var (incl. undefined
  for env-less fields) — now uses formatMissingResources().
- enforceValidation()'s ConfigurationError context built envVars the old way,
  so the structured error listed all fields while the message listed only
  unset ones — now uses unsetEnvVars().
- unsetEnvVars was inserted between formatMissingResources's doc comment and
  the method, orphaning the doc; reordered so each method keeps its own.

Regenerated Class.ResourceRegistry.md.

Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
@MarioCadenas
MarioCadenas enabled auto-merge (squash) July 22, 2026 10:04
@MarioCadenas
MarioCadenas merged commit 2e2af02 into main Jul 22, 2026
10 checks passed
@MarioCadenas
MarioCadenas deleted the fix/resource-validation-error-only-missing branch July 22, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants