bikash-barnwal opened a new pull request, #43216:
URL: https://github.com/apache/superset/pull/43216
### SUMMARY
`SET_DATABASES` built `extra_json` like this:
```ts
extra_json: JSON.parse(db.extra || ''),
```
That fallback can never succeed — the empty string is not valid JSON, so
`JSON.parse('')` always throws:
```
SyntaxError: Unexpected end of JSON input
at Object.forEach [as SET_DATABASES]
(src/SqlLab/reducers/sqlLab.ts:727:36)
```
`extra` is nullable in the metadata database and the API returns it
verbatim, so a single database row without one takes down the entire
`SET_DATABASES` case — not just that row — and with it SQL Lab's database list.
Parsing now goes through a helper returning `{}` for a missing, blank, or
malformed value. Malformed JSON is handled deliberately rather than only the
empty case: one corrupt `extra` should not cost the user every other database
either.
This was found by scanning for the falsy-fallback shape (`x || <invalid
default>`), the same class as the `interval: '0'` and `thresholdValues[i] ||
MIN_SAFE_INTEGER` bugs.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: with one database whose `extra` is null, the reducer throws and the
SQL Lab database dropdown never populates.
After: that database gets `extra_json: {}` and the rest load normally.
### TESTING INSTRUCTIONS
```bash
cd superset-frontend
npm run test -- src/SqlLab/reducers/sqlLab.test.ts
```
**44 tests pass.** Three new cases: `extra: null` (fails on master with the
SyntaxError above), malformed `'{not json'`, and a valid payload that must
still parse through unchanged.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]