Skip to content

fix(cli): wrap Dir.glob strings before calling sub_ext - #85

Merged
ronaldtse merged 3 commits into
mainfrom
fix/cli-verify-string-sub-ext
Jul 21, 2026
Merged

fix(cli): wrap Dir.glob strings before calling sub_ext#85
ronaldtse merged 3 commits into
mainfrom
fix/cli-verify-string-sub-ext

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Fixes the NoMethodError: undefined method sub_ext for String crash that ucode 0.5.0 code_chart extract --verify hit on the first SVG (Dir.glob returns Strings; .sub_ext is a Pathname method).

Also fixes a silent bug in the same path: sidecar JSONs source_cell is string-keyed after JSON.parse, but Verifier::Result#source_cell is read with symbol keys. Without normalization, every positionally-correlated glyph round-tripped into Skipped(:no_location).

Test plan:

  • New CLI integration spec exercises the full extract --verify path against a fixture SVG+JSON pair. Force Verifier::Builder.pick to nil so it runs without resvg/mutool. Would have caught the 0.5.0 regression; it now does.
  • All 100 existing specs in code_chart + cli_spec pass
  • rubocop clean on touched files

Out of scope: positional-correlation failures #57 (U+1166C) and #58 (U+116DA) are pre-existing ucode bugs in the positional matcher (not touched by this PR). Separate investigation.

ucode 0.5.0's code_chart extract --verify crashed with
NoMethodError: undefined method 'sub_ext' for String because
Dir.glob returns Strings, but the post-extract verify pass
called .sub_ext(.json) directly on them. Wrap in Pathname first.

Also fixes a silent bug in the same path: sidecar JSON's
source_cell is string-keyed after JSON.parse, but
Verifier::Result#source_cell reads with symbol keys (:x, :y).
Round-tripping JSON -> Result -> Verifier without normalizing
keys silently dropped source_cell to nil, making every
positionally-correlated glyph return Skipped(:no_location).
transform_keys(&:to_sym) in build_extractor_result_for_verification
fixes the round-trip.

Adds a CLI integration spec that exercises the full
extract --verify path against a fixture SVG+JSON pair. Force
Verifier::Builder.pick to nil so the spec runs without resvg or
mutool. The spec would have caught the 0.5.0 regression; it now does.
The original 'does not crash with NoMethodError on --verify' spec
called described_class.start with the full extract --verify ARGV.
CI fails at extract --block Sidetic because Blocks.txt isn't
present in the UCD cache on a clean runner — the spec guards the
verify path but trips earlier on extract.

Rewrite the spec to:
1. Call build_extractor_result_for_verification directly and
   assert the round-trip Result has symbol-keyed source_cell.
2. Call verify_block directly with a stubbed Verifier and
   assert the path reaches the verifier without raising.

Both targeted specs cover the actual crash (String#sub_ext) without
CI's UCD cache dependency.
The 0.5.0 release bumped lib/ucode/version.rb but missed syncing
config/unicode17_universal_glyph_set.yml#ucode_version. The smoke
spec that asserts the two stay in sync then fails on the next CI
run because the merge of main's version.rb (0.5.0) with this branch's
YAML (0.4.0) creates a mismatch in the CI checkout.

Sync the YAML to match main's post-release version so the smoke spec
passes on the post-0.5.0 merge.
@ronaldtse
ronaldtse merged commit 1a7d461 into main Jul 21, 2026
18 checks passed
@ronaldtse
ronaldtse deleted the fix/cli-verify-string-sub-ext branch July 21, 2026 14:44
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