Skip to content

fix(masters): guard against an empty Metrika counter identity - #808

Merged
axisrow merged 2 commits into
mainfrom
ao/direct-cli-84/masters-648-metrika-identity-guard
Aug 7, 2026
Merged

fix(masters): guard against an empty Metrika counter identity#808
axisrow merged 2 commits into
mainfrom
ao/direct-cli-84/masters-648-metrika-identity-guard

Conversation

@axisrow

@axisrow axisrow commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #801 (Metrika counters in masters update) — a fix that was pushed to that PR's branch after it had already been merged, so it never landed in main. Cherry-picked here as its own PR against current main.

_metrika_counter_identity (added in #801's cycle-review to compare a counter's autocomplete-suggestion text against its read-back tag-display text by numeric id) returned an empty string when a counter's first line ended with a trailing " • " and nothing after it — a malformed/unexpected markup shape. Two different malformed inputs would both collapse to the same empty identity and falsely match each other in _verify_saved's Counter comparison, masking a real save mismatch instead of failing to match anything (the safe fallback this function already documented for the no-separator case).

Now returns the input text unchanged (instead of "") when the last " • "-delimited token is empty.

Test plan

  • pytest tests/test_masters.py -k "TestMetrikaCounterIdentity" — 5 passed
  • Full offline suite pytest -n auto — 3416 passed, 23 skipped, no regressions
  • black/flake8 clean on all changed files

Found via cycle-review (local /review, delayed report — round completed after PR #801 had already merged).

Relates to #648.

🤖 Generated with Claude Code

axisrow added 2 commits August 7, 2026 15:20
_metrika_counter_identity returned an empty string when a counter's
first line ended with a trailing " • " and nothing after it (e.g. a
malformed or unexpected markup shape). Two different malformed inputs
would both collapse to the same empty identity and falsely match each
other in _verify_saved's Counter comparison, masking a real mismatch
instead of failing to match anything -- the intended, safe failure
mode this function already documented for the no-separator case.

Found via cycle-review (/review, delayed report).
… trailing tokens

cycle-review round 2 finding (Codex + /review, both independently):
the exactly-empty guard added in this PR's first commit used bare
truthiness, so a trailing " • " followed only by whitespace (e.g.
"Label •  ") still returned as a non-empty identity -- two different
malformed inputs could again collapse to the same identity and falsely
match in _verify_saved's Counter comparison, the exact failure mode
this PR set out to close.

Switch the guard to identity.strip() and add the whitespace-only
mirrors of the existing empty-token tests.
@axisrow

axisrow commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

🔍 Local review (cycle 1) — round 88b93294-d40c-4fcd-95c1-126123914c34

Reviewed locally (/review + Codex companion), no bots pinged.

Verdict Reviewer Finding Location
FIX claude + codex (independent duplicate) Empty-identity guard used bare truthiness, so a trailing separator followed only by whitespace still slipped through as a non-empty identity and could mask a real save mismatch by matching two unrelated malformed inputs. direct_cli/browser/masters.py:5135-5136

Fixed in 1f4dd7a: guard now checks identity.strip() instead of bare truthiness; added two mirror tests for the whitespace-only case.

@axisrow

axisrow commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

📋 Review summary — all cycles

Cycle Reviewer Finding Verdict Resolution
1 claude + codex (independent duplicate) Empty-identity guard used bare truthiness; a whitespace-only trailing token still slipped through and could mask a real save mismatch. FIX Fixed in 1f4dd7a
2 codex Non-empty identity branch does not normalize surrounding whitespace around a real id; pre-existing, out of scope for this PR. SKIP (deferred) Filed as follow-up #809, out of scope for this PR

Totals: 1 FIX (resolved), 1 deferred to follow-up (#809). Codex round 2 re-review: approve, no material findings against the fixed diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant