Skip to content

Map nested Protobuf message types - #71

Merged
psobot merged 2 commits into
masterfrom
psobot/fix-nested-messages
Aug 7, 2026
Merged

Map nested Protobuf message types#71
psobot merged 2 commits into
masterfrom
psobot/fix-nested-messages

Conversation

@psobot

@psobot psobot commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Problem

ls, cat and unpack fail on any Keynote document containing a grouped table:

NotImplementedError: Don't know how to parse Protobuf message type 6383
ValueError: Failed to deserialize Index/CalculationEngine.iwa

Message type 6383 is TST.GroupByArchive.GroupNodeArchive — a nested message. compute_maps() only walked file.DESCRIPTOR.message_types_by_name, which lists top-level messages only, so nested types referenced by the TSP registry were silently dropped from ID_NAME_MAP.

Index/CalculationEngine.iwa is parsed early, so the failure aborted the whole operation before reaching any slide content — making the tool unusable end-to-end on affected decks. This is not a Keynote-version problem: 6383 is already present in the v14.4 registry, it just never resolved to a class.

Fix

Recurse into DESCRIPTOR.nested_types when building NAME_CLASS_MAP.

before after
NAME_CLASS_MAP 1183 1362
ID_NAME_MAP 590 631 / 631

Every entry in the TSP registry now resolves.

Tests

Adds tests/test_mapping.py, which asserts the mapping is complete rather than waiting for a document to expose a hole. Verified the new tests fail on master (3 failures) and pass with the fix. Full suite: 24 passed.

Also

The generated header embedded __file__ as an absolute path, baking in the path of whoever last ran the dumper. Now repo-relative.

Fixes #46. Fixes #64. Fixes #66. Fixes #70.

The TSP registry refers to messages nested inside other messages (i.e.
TST.GroupByArchive.GroupNodeArchive) exactly as it refers to top-level
ones, but `compute_maps` only walked `DESCRIPTOR.message_types_by_name`,
which lists top-level messages only. Any nested type in the registry was
therefore missing from ID_NAME_MAP, and parsing a document containing one
failed with:

    NotImplementedError: Don't know how to parse Protobuf message type 6383

6383 is TST.GroupByArchive.GroupNodeArchive, which lives in
Index/CalculationEngine.iwa in any document with a grouped table. Because
that file is parsed early, the failure aborted `ls`, `cat` and `unpack`
before reaching any slide content.

Walk nested_types recursively when building NAME_CLASS_MAP. All 631
registry entries now resolve, up from 590. Adds tests/test_mapping.py so a
gap in the mapping fails CI rather than waiting for a bug report.

Also emit a repo-relative path in the generated header, instead of baking
in the absolute path of whoever last ran the dumper.

Fixes #64. Fixes #66. Fixes #70.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179M4xvAKPGrgKpy4AeCsM7
@psobot
psobot merged commit 265217b into master Aug 7, 2026
4 checks passed
@psobot
psobot deleted the psobot/fix-nested-messages branch August 7, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant