fix(FR-2355): handle duplicate TOML keys in config.toml parsing#6107
fix(FR-2355): handle duplicate TOML keys in config.toml parsing#6107ironAiken2 wants to merge 1 commit intomainfrom
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 8.26% (+0.01% 🔼) |
1406/17031 |
| 🔴 | Branches | 7.43% (-0.01% 🔻) |
883/11884 |
| 🔴 | Functions | 5.41% (-0% 🔻) |
258/4767 |
| 🔴 | Lines | 7.95% (+0.01% 🔼) |
1319/16589 |
Show files with reduced coverage 🔻
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🔴 | ... / useWebUIConfig.ts |
21.93% (+0.98% 🔼) |
12.73% (-0.48% 🔻) |
11.76% (-0.74% 🔻) |
22.12% (+0.97% 🔼) |
Test suite run success
775 tests passing in 36 suites.
Report generated by 🧪jest coverage report action from 26193ea
There was a problem hiding this comment.
Pull request overview
This PR hardens config.toml loading in the React WebUI so duplicated keys generated by the webserver don’t cause TOML parsing to fail silently and revert all config options to defaults.
Changes:
- Add a TOML text preprocessor intended to remove duplicate keys within a section before parsing.
- Change
fetchAndParseConfig()to return{ config, error }so callers can distinguish success vs failure paths. - Replace
console.warnwithuseBAILoggerlogging on config load failures and update call sites/tests accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| react/src/hooks/useWebUIConfig.ts | Adds deduplication + new fetch/parse result shape, and switches failure logging to useBAILogger. |
| react/src/hooks/useWebUIConfig.test.ts | Updates tests for new return type and adds a duplicate-key handling test. |
| react/src/helper/loginSessionAuth.ts | Updates call site to new { config } return shape. |
| react/src/components/EduAppLauncher.tsx | Updates call site to new { config } return shape. |
02f0efd to
1ce5c97
Compare
1ce5c97 to
21872b9
Compare
21872b9 to
dbb22ff
Compare
The Backend.AI webserver generates config.toml with duplicate keys
(e.g. two `debug = true` lines), which causes smol-toml to throw.
The error was silently swallowed, falling back to defaults and
making all config options appear disabled.
- Add deduplicateTomlKeys() preprocessing to remove duplicate keys
before TOML parsing (keeps last occurrence)
- Change fetchAndParseConfig return type to { config, error } to
distinguish fetch failure from parse failure
- Add useBAILogger-based error logging for parse failures
- Update all call sites for new return type
- Add test for duplicate key handling
dbb22ff to
26193ea
Compare

Resolves #6091 (FR-2355)
Summary
smol-tomlthrows on duplicate keys in TOML, but the previous code silently swallowed the error, causing all config options to fall back to defaults without any indication to the userfetchAndParseConfigreturn type fromRawTomlConfig | nullto{ config, error }to distinguish fetch failures (network error, non-200, SPA fallback) from parse failures (invalid TOML)configParseErrorStateJotai atom to store parse errors so other hooks can access them<pre>code block, remediation instructions, and early return (skip remaining config checks sincerawConfigisnull)useBAILogger(replacesconsole.warn)loginSessionAuth.ts,EduAppLauncher.tsx) for the new return typeConfigParseError,ConfigParseErrorDesc,ConfigParseErrorFix) across all 21 languagesTest plan
config.toml(e.g.,debug = falseanddebug = trueunder[general]), open the diagnostics page, and verify a critical alert is shown with the parse error message in a code blockconfig.tomlis validconfig.tomlis missing (404)pnpm run test— all 35 useWebUIConfig tests pass🤖 Generated with Claude Code