mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-07-24 23:26:14 +00:00
* fix(frontend): actually clear credential fields when emptied in the edit dialog Clearing base_url (or the Vertex project/location/credentials_path) in the credential edit dialog silently did nothing: the submit handler mapped an emptied field to `undefined`, JSON.stringify dropped the key from the PUT body, and the backend's partial-update semantics kept the old value — while the UI reported success. Emptied fields are now sent as an explicit `null`, which the API already accepts and persists as a cleared value (verified live). UpdateCredentialRequest's nullable fields are typed accordingly. Found in v1.11 release testing (pre-existing, not a release regression): an Ollama credential with a stale IP in base_url could not be cleared from the UI. * fix(api): clear credential fields on explicit null, not just empty string The update handler guarded every field with 'is not None', so a JSON null sent to clear base_url (or endpoint/api_version/endpoint_*/ project/location/credentials_path/num_ctx) was silently skipped — the old value survived while the client saw a 200. Combined with the frontend bug fixed in the previous commit (emptied fields dropped from the payload entirely), clearing a credential field was impossible from the UI: during release testing an Ollama credential kept pointing at a stale IP after being 'cleared', and only an empty-string PUT crafted by hand actually cleared it. Field updates are now keyed on presence in model_fields_set: absent keeps the old value, explicit null or "" clears. name/modalities/ api_key keep their non-null guards (clearing those is not meaningful). Regression tests cover null-clears, empty-string-clears, absent-keeps and the Vertex credentials_path case. * test(frontend): extract credential update payload builder and cover clear-on-empty Addresses the cubic review: the frontend half of the fix had no reproducing test. The edit dialog's payload construction now lives in a pure buildCredentialUpdatePayload() (frontend/src/lib/ credential-update-payload.ts) used by the component, with tests that fail on the original bug: an emptied base_url (and Vertex project/ location/credentials_path) must survive JSON.stringify as an explicit null, unchanged fields must be omitted, and emptied num_ctx clears via 0. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| test-results | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| components.json | ||
| eslint.config.mjs | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| start-server.js | ||
| tsconfig.json | ||
| vitest.config.ts | ||