You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): do not shadow settings.json with the defaults - #1200
ensureConfigBootstrap() runs at the start of nostream start and nostream setup. When .nostr/settings.yaml did not exist it copied resources/default-settings.yaml there. The relay loads settings with settings.yaml first and falls back to the deprecated settings.json only when no yaml exists (loadUserSettings). So on a deployment that still had only a settings.json, the first nostream start created a yaml full of defaults, and from then on the whole settings.json was ignored. Overrides such as nip43.enabled (admission restrictions), payment settings or limits stopped applying without any message, and the relay accepted what it had been configured to refuse (for example events from non-members).
the defaults are now copied only when neithersettings.yaml nor settings.json exists;
a deployment with only a settings.json keeps working on it, as it did before the CLI touched it; the admin console and nostream config write settings.yaml themselves on the first save, and that file is built from the merged settings, so the overrides carry over;
getLegacySettingsFilePath is re-exported from src/cli/utils/paths.ts, next to the other path helpers the CLI uses.
I did not make the bootstrap convert settings.json into a yaml. The suggestion in the issue offered that as a second option, but not shadowing is enough to stop the silent loss, and a conversion would have to reproduce how the loader merges the two files.
Related Issue
Partly addresses #1021 (finding F-042). That issue groups seven findings; this PR only does F-042, so it does not close the issue.
Motivation and Context
Starting the relay through the CLI should not change which settings apply.
How Has This Been Tested?
New test/unit/cli/bootstrap.spec.ts, on a temporary config directory: with no settings the directory is created and the defaults are copied; an existing settings.yaml is left alone, also when a settings.json is there too; a settings.json without a yaml gets no settings.yaml and is not modified; and loadMergedSettings() still returns the settings.json override (nip43.enabled: true) after bootstrapping. Without the fix, the two tests about settings.json fail.
pnpm lint, pnpm check:deps, pnpm run build:check, pnpm run test:unit pass.
Screenshots (if appropriate):
Types of changes
Non-functional change (docs, style, minor refactor)
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation.
I have updated the documentation accordingly.
I have read the CONTRIBUTING document.
I have added tests to cover my code changes.
I added a changeset, or this is docs-only and I added an empty changeset.
All new and existing tests passed.
Summary by CodeRabbit
Bug Fixes
CLI setup now preserves existing settings, including legacy JSON overrides, instead of copying default settings over them.
Default settings are copied only when neither YAML nor legacy JSON settings exist.
When both formats are present, existing YAML settings remain unchanged, and legacy JSON overrides continue to apply until YAML settings are written.
Bootstrap checks for legacy JSON settings before copying defaults. The path helper re-exports the legacy settings path. Tests cover default creation, existing files, and legacy JSON overrides. The changeset records the patch.
cameri/nostream issue 1021: This change addresses the cited bootstrap finding about default YAML overriding legacy JSON settings. The issue includes other findings that this PR does not address.
Merge Risk: Minimal · up to a6462
This change stops CLI startup from creating a default settings.yaml that would hide an existing legacy settings.json. Users with JSON overrides keep them. The change is small, covered by new unit tests, and shows no merge-blocking risk.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(cli): do not shadow settings.json with the defaults" matches the main change. ensureConfigBootstrap now copies default settings only when neither settings.yaml nor the legacy settings.j…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(cli): do not shadow settings.json with the defaults" matches the main change. ensureConfigBootstrap now copies default settings only when neither settings.yaml nor the legacy settings.json exists, so legacy JSON overrides stay effective. The title names the CLI scope, the fix type, and the affected file. It is specific and concise. The supporting paths.ts re-export and the unit tests are secondary and need no mention in the title.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the settings files with care If YAML or JSON waits, defaults stay there No legacy rule is brushed aside Tests keep each settings path supplied The rabbit hops, with config safe inside
Recent review info
Automatic approval policy
Commit: a6462cb52505.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Minimal
Global configuration
Security risk
Not set
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: c0adedbc-158c-4122-bea3-ddc921c03550
Commits
Reviewing files that changed from the base of the PR and between 49dd6f8 and a6462cb.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ensureConfigBootstrap()runs at the start ofnostream startandnostream setup. When.nostr/settings.yamldid not exist it copiedresources/default-settings.yamlthere. The relay loads settings withsettings.yamlfirst and falls back to the deprecatedsettings.jsononly when no yaml exists (loadUserSettings). So on a deployment that still had only asettings.json, the firstnostream startcreated a yaml full of defaults, and from then on the wholesettings.jsonwas ignored. Overrides such asnip43.enabled(admission restrictions), payment settings or limits stopped applying without any message, and the relay accepted what it had been configured to refuse (for example events from non-members).settings.yamlnorsettings.jsonexists;settings.jsonkeeps working on it, as it did before the CLI touched it; the admin console andnostream configwritesettings.yamlthemselves on the first save, and that file is built from the merged settings, so the overrides carry over;getLegacySettingsFilePathis re-exported fromsrc/cli/utils/paths.ts, next to the other path helpers the CLI uses.I did not make the bootstrap convert
settings.jsoninto a yaml. The suggestion in the issue offered that as a second option, but not shadowing is enough to stop the silent loss, and a conversion would have to reproduce how the loader merges the two files.Related Issue
Partly addresses #1021 (finding F-042). That issue groups seven findings; this PR only does F-042, so it does not close the issue.
Motivation and Context
Starting the relay through the CLI should not change which settings apply.
How Has This Been Tested?
New
test/unit/cli/bootstrap.spec.ts, on a temporary config directory: with no settings the directory is created and the defaults are copied; an existingsettings.yamlis left alone, also when asettings.jsonis there too; asettings.jsonwithout a yaml gets nosettings.yamland is not modified; andloadMergedSettings()still returns thesettings.jsonoverride (nip43.enabled: true) after bootstrapping. Without the fix, the two tests aboutsettings.jsonfail.pnpm lint,pnpm check:deps,pnpm run build:check,pnpm run test:unitpass.Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit