Skip to content

Make strict url checks errors; default url protocols to http/https - #1222

Open
theoephraim wants to merge 1 commit into
mainfrom
strict-url-validation-major
Open

theoephraim wants to merge 1 commit into
mainfrom
strict-url-validation-major

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Breaking follow-up to #1220, which added these url checks as warnings. This turns them into errors for the next major.

  • Values must be written as scheme://.... Opaque values that new URL() accepts (SHA256:... fingerprints, user:pass, localhost:3000, mailto:, C:\path) are rejected.
  • Whitespace/control characters, a missing host (unless allowNoHost=true), and malformed http/https/ws/wss/ftp hosts (backslashes, percent-encoded hosts, IPv4 shorthand, empty or hyphen-edged labels) are rejected.
  • Without allowedProtocols, only http and https are allowed. The error tip names the fix (allowedProtocols=[postgres], or allowedProtocols="*" for any).
  • prependHttps now prefixes any value not starting with scheme://. The host:port digit heuristic from Reject ambiguous url hosts under allowedDomains; prependHttps handles host:port #1218 is gone, since opaque URLs are no longer valid anyway.

The VSCode extension reports these as errors (the separate warning path from #1220 is removed). Docs drop the "warning until the next major" notes, and the GitHub Action example's DATABASE_URL sets allowedProtocols.

Not for merge until the major release.

@theoephraim theoephraim added the BREAKING This is a breaking change in varlock core - merge when doing a new major release label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

major Major releases

  • @varlock/1password-plugin 2.0.5 → 3.0.0 (dep)
  • @varlock/akeyless-plugin 2.0.1 → 3.0.0 (dep)
  • @varlock/astro-integration 1.4.3 → 2.0.0 (dep)
  • @varlock/aws-secrets-plugin 1.2.5 → 2.0.0 (dep)
  • @varlock/aws-sigv4-plugin 0.1.2 → 1.0.0 (dep)
  • @varlock/azure-key-vault-plugin 1.3.1 → 2.0.0 (dep)
  • @varlock/bitwarden-plugin 2.0.2 → 3.0.0 (dep)
  • @varlock/cloudflare-integration 1.6.1 → 2.0.0 (dep)
  • @varlock/dashlane-plugin 2.1.2 → 3.0.0 (dep)
  • @varlock/doppler-plugin 2.0.2 → 3.0.0 (dep)
  • @varlock/effect-plugin 0.1.0 → 1.0.0 (dep)
  • @varlock/expo-integration 1.2.1 → 2.0.0 (dep)
  • @varlock/google-secret-manager-plugin 1.2.4 → 2.0.0 (dep)
  • @varlock/hashicorp-vault-plugin 2.1.2 → 3.0.0 (dep)
  • @varlock/infisical-plugin 2.1.3 → 3.0.0 (dep)
  • @varlock/keepass-plugin 2.0.4 → 3.0.0 (dep)
  • @varlock/keeper-plugin 2.0.2 → 3.0.0 (dep)
  • @varlock/kubernetes-plugin 1.0.2 → 2.0.0 (dep)
  • @varlock/native-helper-darwin 1.22.0 → 2.0.0
  • @varlock/native-helper-linux-arm64 1.22.0 → 2.0.0
  • @varlock/native-helper-linux-x64 1.22.0 → 2.0.0
  • @varlock/native-helper-win32-x64 1.22.0 → 2.0.0
  • @varlock/nextjs-integration 1.2.4 → 2.0.0 (dep)
  • @varlock/nuxt-integration 0.1.3 → 1.0.0 (dep)
  • @varlock/pass-plugin 1.0.3 → 2.0.0 (dep)
  • @varlock/passbolt-plugin 2.0.2 → 3.0.0 (dep)
  • @varlock/proton-pass-plugin 2.0.2 → 3.0.0 (dep)
  • @varlock/vite-integration 1.5.3 → 2.0.0 (dep)
  • varlock 1.22.0 → 2.0.0

minor Minor releases

  • env-spec-language 0.4.4 → 0.5.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle size

✅ shrinks the bundle by 2.9 KB (−0.1%)

Metric main This PR Δ
Total dist 5051.5 KB 5048.6 KB −2.9 KB (−0.1%)
JS 1912.0 KB 1910.8 KB −1.1 KB (−0.1%)
Sourcemaps 3009.4 KB 3007.6 KB −1.8 KB (−0.1%)
Type defs 130.2 KB 130.2 KB —
Other 0.0 KB 0.0 KB —

dist/ only; native binaries are versioned separately and not counted here.

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

Important

varlock init still generates URL schemas that reject existing non-HTTP connection strings under the new defaults.

Reviewed changes: Reviewed the runtime URL validation, editor diagnostics, tests, and documentation for this breaking change.

  • Strict validation: Structural URL checks now produce errors, and omitted allowedProtocols permits only HTTP and HTTPS.
  • HTTPS coercion: prependHttps now prefixes any value without a scheme:// prefix.
  • Editor diagnostics: Static validation enforces these rules as errors and removes the transitional warning path.
  • Documentation and release scope: Reference documentation removes transition notes, the Action example explicitly allows PostgreSQL, and the change targets a major Varlock release.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

tip: `Only http and https are allowed unless set explicitly: add \`allowedProtocols=[${protocol}]\`, or \`allowedProtocols="*"\` to allow any.`,
},
));
errors.push(new ValidationError(`Protocol (${protocol}) is not allowed`, {

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.

[P2] Update schema inference alongside the new protocol default. varlock init still emits bare @type=url for _URL/_URI keys and URL-like values, so initializing a project with valid PostgreSQL or Redis connection strings now generates a schema that rejects those same values on load.

Technical details
# Generated schemas conflict with the new URL default

## Affected sites
- `packages/varlock/src/env-graph/lib/data-types.ts:527-531`: omitted `allowedProtocols` now produces an error for non-HTTP protocols.
- `packages/varlock/src/cli/helpers/infer-schema.ts:65-66,83-84`: both key-based and value-based inference emit bare `url`, without protocol options.
- `packages/varlock/src/cli/commands/init.command.ts:140-142,170-172`: initialization uses those inference helpers and writes the resulting schema.

## Reproduction
Passing the following parsed env file through `inferSchemaUpdates` produces bare `# @type=url` decorators on both items:

```dotenv
DATABASE_URL=postgres://localhost/db
REDIS_URL=redis://localhost:6379
```

Loading that generated schema with `EnvGraph` gives `error` for both items: `Protocol (postgres) is not allowed` and `Protocol (redis) is not allowed`. This was verified against the PR head; the existing 316 runtime data-type tests and 31 diagnostics-core tests pass but do not cover this path.

## Required outcome
- Schema inference should preserve valid known non-HTTP connection URLs under the new protocol default, for both existing example items and items inferred from other env files.
- Add regression coverage that infers a schema and loads its original connection values successfully.

## Suggested approach
- Emit explicit `allowedProtocols` for a non-HTTP protocol detected from a valid connection URL rather than weakening the new runtime default.

Inference source: infer-schema.ts.

@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1222

@varlock/astro-integration

npm i https://pkg.pr.new/@varlock/astro-integration@1222

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@1222

@varlock/expo-integration

npm i https://pkg.pr.new/@varlock/expo-integration@1222

@varlock/nextjs-integration

npm i https://pkg.pr.new/@varlock/nextjs-integration@1222

@varlock/nuxt-integration

npm i https://pkg.pr.new/@varlock/nuxt-integration@1222

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@1222

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1222

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1222

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1222

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1222

@varlock/1password-plugin

npm i https://pkg.pr.new/@varlock/1password-plugin@1222

@varlock/akeyless-plugin

npm i https://pkg.pr.new/@varlock/akeyless-plugin@1222

@varlock/aws-secrets-plugin

npm i https://pkg.pr.new/@varlock/aws-secrets-plugin@1222

@varlock/aws-sigv4-plugin

npm i https://pkg.pr.new/@varlock/aws-sigv4-plugin@1222

@varlock/azure-key-vault-plugin

npm i https://pkg.pr.new/@varlock/azure-key-vault-plugin@1222

@varlock/bitwarden-plugin

npm i https://pkg.pr.new/@varlock/bitwarden-plugin@1222

@varlock/dashlane-plugin

npm i https://pkg.pr.new/@varlock/dashlane-plugin@1222

@varlock/doppler-plugin

npm i https://pkg.pr.new/@varlock/doppler-plugin@1222

@varlock/effect-plugin

npm i https://pkg.pr.new/@varlock/effect-plugin@1222

@varlock/google-secret-manager-plugin

npm i https://pkg.pr.new/@varlock/google-secret-manager-plugin@1222

@varlock/hashicorp-vault-plugin

npm i https://pkg.pr.new/@varlock/hashicorp-vault-plugin@1222

@varlock/infisical-plugin

npm i https://pkg.pr.new/@varlock/infisical-plugin@1222

@varlock/keepass-plugin

npm i https://pkg.pr.new/@varlock/keepass-plugin@1222

@varlock/keeper-plugin

npm i https://pkg.pr.new/@varlock/keeper-plugin@1222

@varlock/kubernetes-plugin

npm i https://pkg.pr.new/@varlock/kubernetes-plugin@1222

@varlock/pass-plugin

npm i https://pkg.pr.new/@varlock/pass-plugin@1222

@varlock/passbolt-plugin

npm i https://pkg.pr.new/@varlock/passbolt-plugin@1222

@varlock/proton-pass-plugin

npm i https://pkg.pr.new/@varlock/proton-pass-plugin@1222

commit: 5971606

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 5971606 Commit Preview URL

Branch Preview URL
Oct 13 2026, 09:29 PM

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

Labels

BREAKING This is a breaking change in varlock core - merge when doing a new major release core:varlock core:vscode-plugin core:website maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant