feat(config): require merged top-level defaults#1514
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1514 +/- ##
==========================================
+ Coverage 90.10% 90.65% +0.54%
==========================================
Files 69 69
Lines 5657 5690 +33
Branches 990 985 -5
==========================================
+ Hits 5097 5158 +61
+ Misses 541 514 -27
+ Partials 19 18 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jescalada
left a comment
There was a problem hiding this comment.
LGTM after fixing CI 🚀 Just wondering if we should go ahead and deprecate the old fields to simplify the implementation a bit. It would also help clean up our config files and docs.
…emPath fields These top-level fields were already marked deprecated in the schema: - proxyUrl: superseded by repository-URL-based proxying - sslKeyPemPath / sslCertPemPath: superseded by tls.key / tls.cert Drop them from the schema, regenerate the TypeScript types and reference docs, and remove the legacy fallback logic from the config module. This also lets us simplify FullGitProxyConfig to plain Required<GitProxyConfig>.
|
Thanks for the review @jescalada! Pushed two commits:
This is a breaking change for any users still relying on the deprecated fields, but since they were already marked |
There was a problem hiding this comment.
After the recent changes, using deprecated configs (those that still contain the proxyUrl/sslKeyPemPath/sslCertPemPath) or using a config with a non-existent key (such as invalidKey) throws the following error when starting the proxy:
[0] Error: Failed to load configuration: Invalid value for key "invalidKey" on GitProxyConfig. Expected boolean but got false
[0] at handleErrorAndThrow (/home/juan/Desktop/Juan/Projects/git-proxy/src/utils/errors.ts:32:9)
[0] at defaultSettings (/home/juan/Desktop/Juan/Projects/git-proxy/src/config/index.ts:426:3)
[0] at Object.<anonymous> (/home/juan/Desktop/Juan/Projects/git-proxy/src/config/index.ts:428:1)
[0] at Module._compile (node:internal/modules/cjs/loader:1562:14)
[0] at Object.transformer (/home/juan/Desktop/Juan/Projects/git-proxy/node_modules/tsx/dist/register-D46fvsV_.cjs:3:1104)
[0] at Module.load (node:internal/modules/cjs/loader:1313:32)
[0] at Function._load (node:internal/modules/cjs/loader:1123:12)
[0] at TracingChannel.traceSync (node:diagnostics_channel:322:14)
[0] at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
[0] at Module.require (node:internal/modules/cjs/loader:1335:12)
[0]
[0] Node.js v22.13.1
[0] npm run server exited with code 1Note the "expected boolean but got X" bit - it still fails when setting a boolean value like this:
"invalidKey": false
If removing those fields, we would want a more descriptive/accurate error so people know those fields are missing or no longer available, rather than the type being mistaken as the current error message implies.
I'm thinking the deprecation removal would be best implemented in a separate PR even if the config default requirement implementation is a bit messy on this PR. I'm happy to merge the PR in the previous state with the CI fixes added in.
Pinging @kriswest for thoughts on removing deprecated proxyUrl/sslKeyPemPath/sslCertPemPath soon - I don't think anybody in v2.0 is still using these at all...
…sslCertPemPath fields" This reverts commit c48d0bf. Removing these fields is a breaking change for existing 2.x configs. Keep them in the schema as deprecated and defer removal to the next major (3.0).
|
Reverted the This PR is now back to just the config defaults work (the original goal + the |
|
Tracked the eventual removal as #1545 (3.0). That issue also captures your suggestion about a clearer error message for removed/unknown fields. |
Summary
Fixes #1287.
This updates config loading so user override files can keep using the generated optional
GitProxyConfigtype, while the merged runtime configuration is narrowed to a stricterFullGitProxyConfigafter defaults are applied and verified.Changes
FullGitProxyConfigtype for the merged runtime configuration.Validation
npm run check-types:servernpm test -- test/testConfig.test.tsnpm run lint