Skip to content

Content query: per-file read errors, missing join columns, and three reader edge cases - #2127

Merged
abrignoni merged 10 commits into
abrignoni:mainfrom
Maxitelmo:fix/content-query-followups
Nov 26, 2026
Merged

abrignoni merged 10 commits into
abrignoni:mainfrom
Maxitelmo:fix/content-query-followups

Conversation

@Maxitelmo

@Maxitelmo Maxitelmo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2093, the five follow-ups from the review of #2082. Each has a test that fails on main and passes here.

scripts/content_query_reader.py

  • Row framing (item 3). The first column now comes from the first Row: 0 line, not from a vote over every line that looks like a row. Lines inside a value like Row: 1 example=x can no longer outvote _id and turn the dump into unrecognised text. The vote is kept only for a text with no Row: 0 line. Test: test_row_lines_inside_a_value_do_not_outvote_the_first_column.
  • Delimiter at the start of a value (item 4). A value holding , <column>= is flagged at any offset, including offset zero. A value that starts with a plain name= is still not flagged. Test: test_delimiter_at_the_start_of_a_value_is_flagged.
  • Very long times (item 5). int() moved inside the guarded block. A value past Python's 4,300-digit limit is reported as out of range, and the note gives its digit count instead of the whole value. Test: test_unset_and_bad_values.

scripts/artifacts/contentQuery.py

  • One unreadable file (item 1). An OSError on a matched file is caught per file. That file's rows are skipped with a log line, its path stays in the source list, and the other folders are still read. Content Query Files shows it as file not readable. The error text keeps the exception class and strerror only, because str(OSError) holds the full local path. The same change covers the sibling read in the MMS joins, which put that path in Parse Note before. Tests: UnreadableFileTest.
  • Missing join columns (item 2). If mms_addr.txt has rows but no msg_id or type column, or mms.txt has rows but no _id column, the join treats that file as incomplete. Unmatched rows then say unknown with the reason, instead of "no address rows" or no. Test: test_missing_join_columns_leave_the_relation_unknown.
  • Notes updated for both. last_update_date is 2026-11-26 on all twelve artifacts, since the reader and _read changes reach all of them.

Also in this PR, from its review

  • alex_reader_edges, a synthetic case for the reader fixes. On main its SMS, MMS and Content Query Files units fail.
  • Most of Content query reader: a row-like line before the first real row #2130 (a row-like line before the rows), and a sequence quoted inside a value: when the earliest Row: 0 is followed by a Row: 1 with the same first column it is kept, and otherwise up to four readings are compared. Four or more distinct row-like lines before the rows stay in Content query reader: a row-like line before the first real row #2130.
  • Two performance fixes in that code: the repeated-name check is now linear (a 59,478 row dump with a quoted Row: 0 line did not finish before), and the row-like lines are found once, with at most four names collected and only the best reading kept.
  • Notes audit by @abrignoni (1935e2e): what 'file not readable' covers, and no projection named as the cause of a missing column.

Checks (at 1935e2e)

  • run_test_cases.py --module contentQuery --strict: 39 PASS. The baselines that were there before are unchanged, and the four new ones are from alex_reader_edges.
  • --storage-views: 72 SKIP. These are tool output folders, not app containers.
  • The content query reader and artifact unit tests (44) pass. The CI check scripts and lint_changed.py are clean.
  • The full unittest discover gave the same failures on this branch as on main in a local Windows run (last compared at 6b4ea83).

🤖 Generated with Claude Code

Maxitelmo and others added 2 commits November 26, 2026 12:59
…iter at the start of a value, keep very long times from raising

- The first column is taken from the first 'Row: 0' line instead of a
  vote over every line that looks like a row, so 'Row: <n> <word>='
  lines inside a value cannot outvote it and turn the dump into
  unrecognised text. The vote stays for a text with no 'Row: 0' line.
- A value that holds ', <name>=' for a column of the dump is flagged
  at any offset, including offset zero; a value that starts with a
  plain 'name=' is not.
- A time with more digits than Python's integer string conversion
  limit is reported as out of range instead of raising ValueError.

Items 3 to 5 of abrignoni#2093.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ut the join columns as incomplete

- An OSError on a matched file no longer stops the artifact: that
  file's rows are skipped with a log line, its path stays in the source
  list, the other folders are still read, and Content Query Files shows
  it as 'file not readable'. The error text names the exception class
  and strerror only, since str(OSError) holds the local path; this also
  covers the sibling read of the MMS joins, which put it in Parse Note.
- If mms_addr.txt has rows but no msg_id or type column, or mms.txt has
  rows but no _id column, the join takes that file as incomplete, so an
  unmatched row says unknown with the reason instead of a definite no.
- Notes updated; last_update_date 2026-11-26 on the twelve artifacts.

Items 1 and 2 of abrignoni#2093.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the mac-review Enrolled for local review on the maintainer Mac label Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Test data is now included for every changed artifact module. Thank you!

@github-actions github-actions Bot added the needs-test-data Artifact PR without test data for the changed modules label Nov 26, 2026

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
A synthetic ALEX case for the module test harness, so CI keeps the
fixes of this PR: an sms.txt whose first body holds four
'Row: <n> example=' lines (more than the real rows), a body that starts
with ', seen=' and a date of 5,000 digits; and an mms.txt with an
mms_addr.txt whose rows print no msg_id column. Run on main, the SMS,
MMS and Content Query Files units of this case fail (the SMS dump is
read as unrecognised text and gives no rows); on this branch all 39
units pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Maxitelmo and others added 2 commits November 26, 2026 13:42
…t first columns

Taking the first 'Row: 0' line as row 0 lost the real rows when a
row-like line came before them ('Row: 0 example=x', then 'Row: 0 _id=1',
'Row: 1 _id=2'), a case the vote of abrignoni#2082 read correctly. When 'Row: 0'
lines name different first columns, each reading is now tried and the
one kept has the fewest rows that cannot be split, then the least text
before its first row, then the earliest 'Row: 0'. A single real row
whose value quotes 'Row: 0' and 'Row: 1' lines still keeps its own
first column. Tests for both.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the Row: 0 readings

Trying a wrong 'Row: 0' reading on a large dump makes the whole text one
row of hundreds of thousands of names, and the repeated-name check
(columns.count for each name) was quadratic over that list: a 59,478
row MediaStore-sized dump with one quoted 'Row: 0' line did not finish
in five minutes. It now counts with a Counter (1.9 s for that dump), and
at most four 'Row: 0' readings are tried (3.0 s with twenty quoted
names). Test with a 20,000 row dump.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed the needs-test-data Artifact PR without test data for the changed modules label Nov 26, 2026
@Maxitelmo

Copy link
Copy Markdown
Contributor Author

Pushed three more commits:

  • 868938a: a synthetic test case, alex_reader_edges, for the reader fixes. It has an sms.txt whose first body holds four Row: <n> example= lines, a body that starts with , seen=, and a date of 5,000 digits. It also has an mms.txt whose mms_addr.txt prints no msg_id column. On main, the SMS, MMS and Content Query Files units of this case fail: the SMS dump is read as unrecognised text. On this branch, all 39 strict units pass.
  • 51e18af: fixes Content query reader: a row-like line before the first real row #2130, the row-like line before the first real row. When Row: 0 lines name different first columns, each reading is tried. The one kept has the fewest rows that cannot be split, then the least text before its first row, then the earliest Row: 0. The example from the review gives the two _id rows again, with a warning for the line left before them. A single real row whose value quotes Row: 0 and Row: 1 keeps its own first column. There is a test for each.
  • 578cb6e: a hang I found while testing 51e18af on a dump the size of a real MediaStore (59,478 rows). A wrong reading makes the whole text one row of a few hundred thousand names, and the repeated-name check from Read saved content query text from android_triage and ALEX raw text output #2082 was quadratic over that list. With one quoted Row: 0 line, it did not finish in five minutes. It now counts in linear time, and at most four readings are tried: 1.9 s for that dump, 3.0 s with twenty quoted names. The test uses a 20,000 row dump.

51e18af and 578cb6e belong together. If you'd rather keep #2130 out of this PR, I can move both to a separate one.

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
…a sequence

Comparing readings let a sequence quoted inside an SMS body replace the
real rows: three real '_id' rows, the last one not splittable, whose
body quotes 'Row: 0 example=x' and 'Row: 1 example=y', gave the two
quoted lines as the rows. The earliest 'Row: 0' reading is now kept
whenever a 'Row: 1' line with the same first column follows it; the
readings are compared only when it does not (a row-like line before
the rows, or a single real row that quotes rows). Test with the
example from the review.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
… a set

_row_zero_names checked each new name against the whole list, which was
quadratic in the number of distinct 'Row: 0' names (40,000 took 11.4 s)
although at most MAX_READINGS of them are ever tried. It now keeps a set
for membership, preserves the order in the list, and stops at
MAX_READINGS names (0.19 s for the same text). Test with 40,000 names.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
parse_text collected the 'Row: 0' names from one scan of the lines,
_row_starts made its own, and _row_starts called _row_zero_names for a
third while holding its list. The candidates are now found once in
parse_text and passed to both helpers, and released before the rows are
split on the usual paths. Same output; a 59,478 row dump parses in
1.13 s instead of 1.30 s with the same peak memory.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
…ng them

The fallback kept every parsed reading until it picked one, so a single
row whose value quotes several distinct 'Row: 0' markers before a large
tail held up to four parsed copies of that tail. It now keeps only the
best score and dump seen so far, with the same tie-breaking. Same
output; 64 MB to 46 MB peak on a row quoting four markers before a
200,000 line tail.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
…rojection cause

file not readable covers a copy ALEAPP could open or read, Detail gives the
class and system text, and a failed copy into the report folder can show as
FileNotFoundError with the cause in the run log. A missing msg_id or type
column no longer names a projection as its cause, since neither ALEX nor
android_triage uses one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni

Copy link
Copy Markdown
Owner

Maxi, I pushed a notes-only commit (1935e2e) after a notes audit: "file not readable" now says ALEAPP could not open or read its copy, and that a failed copy into the report folder can show FileNotFoundError with the cause in the run log. The MMS note no longer names a projection as the cause of a missing column, since neither ALEX nor android_triage uses one. Your description still says 35 strict cases and 39 unit tests; at this head it is 39 and 44.

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Maxi, nice work on all five. Merging.

@abrignoni
abrignoni merged commit 81db5b8 into abrignoni:main Nov 26, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mac-review Enrolled for local review on the maintainer Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content query reader: per-file read errors and missing join columns

2 participants