Skip to content

Warn when a forEnv() arg can never match - #1287

Open
voiys wants to merge 1 commit into
dmno-dev:mainfrom
voiys:warn-forenv-unknown-env
Open

voiys wants to merge 1 commit into
dmno-dev:mainfrom
voiys:warn-forenv-unknown-env

Conversation

@voiys

@voiys voiys commented Nov 10, 2026

Copy link
Copy Markdown
Contributor
# @currentEnv=$APP_ENV
# ---
# @type=enum(development, production)
APP_ENV=development

# @required=forEnv(prodution) @type=url
API_URL=

$ APP_ENV=production varlock load
main:
  ✅ API_URL
     └ undefined                                 (exit 0, nothing says the url is missing)
here:
  🧐 API_URL
     └ undefined
     - [WARNING] forEnv(): "prodution" is not a possible value of APP_ENV
       (the @currentEnv item: development, production), so it can never match.
       Did you mean "production"?

only checked when the @currentEnv item is a plain enum(...) with literal members and the arg is written out literally. forEnv($OTHER) and computed enums are left alone.

it's a warning, not an error, so a schema with a stale env name still loads.

the "did you mean" uses the same edit-distance helper the CLI already had for mistyped flags, moved to lib/suggest-closest.ts.

test: forenv-env-names.test.ts.

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes: Reviewed the literal forEnv() argument checks, their graph lifecycle integration, and the shared suggestion helper.

  • Enum diagnostics: Warns about impossible literal arguments while preserving warning-only behavior and parent-versus-child environment selection.
  • Shared suggestions: Extracts edit-distance matching, preserves CLI dash normalization, and bounds suggestion input lengths.
  • Coverage and docs: Adds regression tests and documents when arguments are checked. All 194 focused and adjacent tests passed.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

A static forEnv() arg that is not a member of the @currentEnv item's enum
can never match, so @required=forEnv(prodution) silently never requires
anything. It is now a warning with the closest enum value as a hint.
Only checked when the item is a plain enum with literal members.
@theoephraim
theoephraim force-pushed the warn-forenv-unknown-env branch from 65cc6d7 to 14573a2 Compare November 13, 2026 00:47

This branch has not been deployed

No deployments
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.

1 participant