Repository navigation
fix(frontend/settings): keep a stored default_coverage of 0 on load - #510
Merged
Merged
Conversation
loadGlobalSettings read default_coverage with `|| 80`, so a stored 0 rendered as 80 in the Target coverage input and in the cached global default behind the override modal's "Inherit (currently: X%)" label. An unedited Save then PUT default_coverage 80, and since #500 the changed global also propagates 80 to every service config's coverage. Use `?? 80` at both sites so only an absent value falls back to 80, matching the per-service coverage inputs. The backend accepts 0-100. Closes #135
Contributor
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 14 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Your 51 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
loadGlobalSettingsread the global target coverage with||:A stored
default_coverageof0therefore rendered as80in the Target coverage input and in the cache behind the account-override modal's "Inherit (currently: X%)" placeholder. Both sites now use?? 80, so only an absent (undefined/null) value falls back to 80. This matches the per-service coverage inputs in the same function (svc?.coverage ?? data.global?.default_coverage ?? 80).Why
An operator with global coverage
0who opened Settings to change something else (e.g. the notification email) and clicked Save silently PUTdefault_coverage: 80. Since #500 a changed global default is also copied to theservice_configs.coveragerows in the same transaction. The Settings page then PUTs each service again with its own stored value, so services that already had a stored row end up with their stored coverage; the services affected were the ones without a stored row, such as the RI cards (no per-card coverage input), which sentcoverage: 80because their save path falls back tosettings.default_coverage. Review also found that the Settings Save never propagates a changed global coverage to services that have a stored row; that is tracked separately.0 is a valid value end to end: the save path accepts 0-100 (
settings.tsvalidation),config.validateCoverageusesMinCoverage = 0, the openapi schema documents 0-100, andupdateConfigjson-unmarshals the body over the stored row, so a sent 0 is stored as 0.How verified
New tests in
frontend/src/__tests__/settings.test.ts(issue #135block) driveloadGlobalSettingsthen an uneditedsaveGlobalSettings:0, SP coverage input shows0,updateConfiggetsdefault_coverage: 0, the compute SP and EC2 RI service saves getcoverage: 0default_coverage: input shows80and Save sends80(existing default kept)0, saves0; sibling card inherits50Inherit (currently: 0%)Before the fix (origin/main source, new tests):
After:
Tests: 77 skipped, 4 passed, 81 total. Mutation: reverting only the cache line to||fails the override-label test (Received: "Inherit (currently: 80%)").Full frontend:
npm run typecheckclean;npx jest --watchman=false92 suites, 3040 passed, 1 skipped;npx eslinton both touched files clean;npm run buildcompiles (only the existing entrypoint-size warning). These are jsdom/mocked-API tests, not a run against the real stack.Left alone (zero-vs-absent sites seen, out of scope; #151 tracks the sweep)
settings.tssame block:default_term || 3,default_payment || 'all-upfront'(load and cache),notification_days_before || 3. 0 is not a valid term or notify-days value, so these are harmless today.internal/api/handler_dashboard.goresolveTargetCoverage:DefaultCoverage > 0else80.0, so the dashboard shows an 80% target when the configured global is 0. Backend half of the same field; left for an owner call on whether the dashboard should show 0%.settings.tssave path: per-card coverage keeps the base value when the input is empty (rawCov !== ''), which is presence-based and fine.Closes #135