Skip to content

feat(config): require merged top-level defaults#1514

Merged
jescalada merged 9 commits into
finos:mainfrom
dcoric:feat/require-config-defaults
May 27, 2026
Merged

feat(config): require merged top-level defaults#1514
jescalada merged 9 commits into
finos:mainfrom
dcoric:feat/require-config-defaults

Conversation

@dcoric

@dcoric dcoric commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1287.

This updates config loading so user override files can keep using the generated optional GitProxyConfig type, while the merged runtime configuration is narrowed to a stricter FullGitProxyConfig after defaults are applied and verified.

Changes

  • Add a FullGitProxyConfig type for the merged runtime configuration.
  • Validate that default-backed top-level config values are present after merging defaults and user overrides.
  • Keep deprecated compatibility fields optional where the default config does not set them.
  • Remove fallback values from config accessors that now read from the validated merged config.
  • Remove the duplicate session max-age fallback in service session setup.
  • Add tests covering defaulted top-level values and partial user overrides.

Validation

  • npm run check-types:server
  • npm test -- test/testConfig.test.ts
  • Commit hook ran prettier, eslint fixes, and npm run lint

@netlify

netlify Bot commented Apr 29, 2026

Copy link
Copy Markdown

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit 4234c16
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6a10e320dadbb7000843be21
😎 Deploy Preview https://deploy-preview-1514.git-proxy.preview.finos.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (a60e51a) to head (4234c16).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dcoric dcoric marked this pull request as ready for review April 29, 2026 12:52
@dcoric dcoric requested a review from a team as a code owner April 29, 2026 12:52

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

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.

Comment thread src/config/index.ts
Comment thread src/config/index.ts
Comment thread src/config/index.ts
dcoric added 2 commits May 21, 2026 13:44
…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>.
@dcoric

dcoric commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @jescalada! Pushed two commits:

  1. fix(config): add upstreamProxy to required top-level keys — addresses the CI failure you flagged after my main merge brought in upstreamProxy.
  2. refactor(config): remove deprecated proxyUrl, sslKeyPemPath, sslCertPemPath fields — takes you up on the deprecation suggestion. Drops the deprecated fields from the schema, regenerates the TS types and reference docs, removes the legacy fallback logic, and simplifies FullGitProxyConfig to plain Required<GitProxyConfig> (so the OptionalTopLevelConfigKey indirection is gone).

This is a breaking change for any users still relying on the deprecated fields, but since they were already marked deprecated: true in the schema and tls.key / tls.cert have been the documented path for a while, hopefully that's acceptable. Happy to split the deprecation removal into a separate PR if you'd prefer to merge the CI fix on its own first.

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

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 1

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

jescalada and others added 2 commits May 22, 2026 21:25
…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).
@dcoric

dcoric commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Reverted the refactor(config): remove deprecated proxyUrl, sslKeyPemPath, sslCertPemPath fields commit (4234c16) — agreed it's better to keep the deprecation removal out of this PR. The deprecated fields stay in the schema (still flagged deprecated: true) and the legacy fallback logic is restored, so this avoids the breaking change for 2.x users. Happy to follow up with a separate PR targeting 3.0 for the actual removal, with the more descriptive error message you mentioned for missing/removed fields.

This PR is now back to just the config defaults work (the original goal + the upstreamProxy CI fix). Ready for another look @jescalada.

@dcoric

dcoric commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

Tracked the eventual removal as #1545 (3.0). That issue also captures your suggestion about a clearer error message for removed/unknown fields.

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

LGTM

@jescalada jescalada merged commit 1602e54 into finos:main May 27, 2026
25 checks passed
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.

Require top-level config values while allowing to override config file

2 participants