Repository navigation
Fix five real bugs found in an adversarial code-review pass - #24
Merged
Merged
Conversation
…alog 1. The scrollbar visibly floated ~46px away from the canvas it scrolls at any dialog width. Its grid column also holds the Save button (a different row), which is wider than the scrollbar itself, so the column widens to fit the button — and without an explicit horizontal sticky, the scrollbar centered in that wider column instead of hugging the canvas. Fixed by sticking it to the column's west edge, verified empirically at two widths (900px, 500px) via real Tk geometry introspection, not visual inspection. 2. The "Checked" checkbox was attached to its group by matching the literal string "Classification" against _EDIT_FIELD_GROUPS' titles in two separate places. Renaming that group anywhere would silently break dialog construction (an assert failure, or a bare TclError under python -O). Extracted _EDIT_CHECKED_GROUP_TITLE so both sites read from one constant that can't desync. Added a regression test for (1), confirmed to fail against the pre-fix code and pass against the fix.
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
Adversarial code-review pass, in two rounds: the Edit Movie dialog (most recently changed code), then the higher-risk
native.py/storage.pybyte-parsing code. Five real bugs found, each verified empirically before and after the fix, each with a regression test confirmed to fail against the pre-fix code.Round 1 —
gui.py(Edit Movie dialog):stickythe scrollbar centered in that wider column instead of hugging the canvas edge. Verified with real Tk geometry introspection (winfo_x()/winfo_width()): a consistent 46px gap at 900px width, reproduced again at 500px. Fixed withsticky="nsw"."Classification"against_EDIT_FIELD_GROUPS' titles in two separate places. Renaming that group anywhere would silently break dialog construction. Extracted_EDIT_CHECKED_GROUP_TITLEso both sites read from one constant.Round 2 —
storage.py(interchange formats):copy_catalogsilently corrupted every XML/CSV backup/restore. It validates through a same-directory temporary file whose name is always a UUID-qualified.tmp(unique_temporary_path), never the catalog's real suffix.load()'s dispatch is suffix-based for everything except native.amc(content-sniffed) and JSON (the fallback) — so a byte-identical copy of a valid XML or CSV catalog was always misread as JSON and rejected with aJSONDecodeError.amc backup/amc restore(and the desktop's Backup/Restore actions) were completely broken for any catalog opened directly from.xmlor.csv. Fixed with an explicitsuffix_hintparameter onload(), passed as the source's own suffix..replace(), notstr.format()— the doubled braces in its CSS (body{{font-family:...}}) were never collapsed to single braces, so every default (no custom template) export shipped literally invalid CSS: unstyled tables, no borders, no header background. Fixed by writing the CSS with single braces._camel_to_snake/_snake_to_camelwere not true inverses._snake_to_camelalready special-cased renames a generic regex can't produce (extension↔Ext,field_type↔Type,gui_properties↔GUIProperties, etc.), but_camel_to_snakehad no matching table — it inserted an underscore before every capital letter unconditionally, turningGUIPropertiesintog_u_i_properties. A native-loaded catalog stores this under the correctgui_propertieskey, so exporting it to XML silently dropped theGUIProperties/Type/etc. attributes — masked in every existing test because an XML-to-XML round trip applies the same broken function on both sides and agrees with itself on the wrong key. Fixed by giving_camel_to_snakethe same special-case table, inverted, falling back to an acronym-aware regex otherwise.Verified but not fixed, flagged for a separate decision:
write_native_catalogbase64-decodes every movie's (and supplementary record's) picture twice per save — once during pre-write budget validation, once again inside_write_movie_42. Confirmed real via code inspection, but it's a performance-only issue (same bytes, decoded twice — no functional bug) on a well-tested, budget-sensitive hot path. Didn't want to restructure that code without a separate check-in.Test plan
test_edit_dialog_scrollbar_has_no_gap_from_its_canvas— confirmed to fail against the pre-fix code (reproducing the exact 46px gap) and pass against the fix.test_copy_catalog_validates_non_json_formats_by_their_real_suffix(parametrized XML/CSV) — confirmed to fail with the originalJSONDecodeErroragainst the pre-fix code.test_html_export_default_template_has_valid_css— confirmed to fail (doubled braces present) against the pre-fix code.test_xml_roundtrip_preserves_catalog_and_custom_field_metadatato assert exact key names (gui_properties,field_type), not just XML-to-XML self-consistency.test_xml_export_writes_gui_properties_from_a_native_loaded_catalog— a cross-format case a self-consistent-but-wrong round trip cannot satisfy.tools/check.py— 670 tests pass, ruff/mypy/format clean, 88% coverage.