fix(android): Add missing Android binary chunk types and improve parsing robustness#626
Conversation
📲 Install BuildsiOS
Android
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a14cd7e. Configure here.
| return ChunkHeader( | ||
| start_offset=start_offset, | ||
| chunk_type=ChunkType(chunk_type), | ||
| chunk_type=parsed_chunk_type, |
There was a problem hiding this comment.
Unknown chunk types still crash in parse_resource_table
Medium Severity
The read_chunk_header change now allows unknown chunk type integers to pass through instead of crashing, but parse_resource_table still raises a ValueError in its else branch for any chunk type that isn't STRING_POOL, TABLE_PACKAGE, or NULL. Before this PR, unknown types would crash earlier in read_chunk_header; now they flow through and crash at line 560 instead. Both parse_xml and read_package gracefully skip unknown chunks, but parse_resource_table does not, creating an inconsistency that undermines the forward-compatibility goal.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a14cd7e. Configure here.


This PR addresses a
ValueError: 516 is not a valid ChunkTypethat occurred when parsing Android APKs containing newer resource table chunk types.Changes Made:
ChunkTypeenum: AddedTABLE_OVERLAYABLE = 0x0204,TABLE_OVERLAYABLE_POLICY = 0x0205, andTABLE_STAGED_ALIAS = 0x0206tosrc/launchpad/parsers/android/binary/types.py. These chunk types were introduced in Android 10+ and were previously missing, causing parsing failures.read_chunk_headerrobustness: Modifiedread_chunk_header()insrc/launchpad/parsers/android/binary/android_binary_parser.pyto gracefully handle unknownchunk_typevalues. Instead of raising aValueErrorwhen an unrecognized integer is encountered, it now stores the raw integer value. This allows the parser to continue processing, withread_package()'s existing fallback logic to skip unknown chunks.ChunkHeadertype hint: Changed the type annotation forChunkHeader.chunk_typetoUnion[ChunkType, int]insrc/launchpad/parsers/android/binary/types.pyto reflect that it can now hold either a knownChunkTypeenum member or an unknown integer value.Why these changes:
The previous implementation of the Android binary parser's
ChunkTypeenum was incomplete, leading to crashes when processing APKs that included newer Android resource table formats. Specifically, theValueErrorwas triggered by0x0204(TABLE_OVERLAYABLE). These changes ensure that the parser can correctly identify and process known modern chunk types, and gracefully skip any future unknown chunk types without crashing, improving the overall robustness and forward compatibility of the Android artifact processing.Fixes LAUNCHPAD-7P