Repository navigation
fix(wallet): match the Key column filter to what the column displays - #219
Merged
Merged
Conversation
The transaction table's Key column renders `key_name || key_label` (JS `||`
treats the empty string as absent), but the server-side `key_name` column
filter compared `COALESCE(ak.name, <key_label>)` — and COALESCE only falls
back on NULL.
`api_keys.name` defaults to the empty string, not NULL (`name TEXT NOT NULL
DEFAULT ''` in db.rs), and the distribution key auto-created at login is
exactly that (`dao::get_or_create_api_key` inserts `''`). So for the common
case the column shows the fallback label ("deepseek / deepseek-paygo") while
filtering by that very text returned 0 rows.
Normalise the empty name to NULL before the COALESCE (`NULLIF(ak.name, '')`)
so the filter and the renderer share one definition of "the key's name".
Regression test seeds an empty-name distribution key and asserts filtering by
the displayed fallback matches it, plus a named-key positive control and a
negative control (after renaming, the old fallback no longer matches).
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.
Summary
The transactions table's Key column and its Key column filter disagreed on what "the key's name" is.
key_name || key_label(JS||treats""as absent), so a key whoseapi_keys.nameis empty shows the fallback label — e.g.deepseek / deepseek-paygo(from the upstream key'snote/provider / plan).COALESCE(ak.name, <key_label>).COALESCEonly falls back on NULL, butapi_keys.nameisTEXT NOT NULL DEFAULT ''— and the distribution key auto-created at login is exactly that (dao::get_or_create_api_keyinserts withname = '').Result: for the common case (user's auto-created key, never renamed), typing into the Key filter the text the table displays returned 0 rows.
Fix: normalise the empty name to NULL first (
NULLIF(ak.name, '')) so the filter and the renderer share one definition. ASCII names and named keys are unchanged.Related Issue
(none — self-discovered during recon; no matching open issue)
Changes
src/routes/wallet.rs—tx_wherekey_name branch:COALESCE(NULLIF(ak.name, ''), …), with the reasoning recorded in the comment.transactions_key_filter_matches_the_displayed_fallback(seeds an empty-name distribution key, asserts the displayed fallback matches; named-key positive control; negative control after rename).Tests
cargo test— 223 passed (was 222; +1 new test)cargo fmt --checkpassescargo clippy --all-targetsclean, no new warningsA/B: reverting only the one-line fix makes exactly the new test fail (rejects the pre-change tree); 222 other tests stay green.
Checklist
fix/…)