Skip to content

Fix parsing of Polygon statement metadata - #46

Open
mfornet wants to merge 1 commit into
kunyavskiy:masterfrom
mfornet:agent/fix-statement-metadata
Open

Fix parsing of Polygon statement metadata#46
mfornet wants to merge 1 commit into
kunyavskiy:masterfrom
mfornet:agent/fix-statement-metadata

Conversation

@mfornet

@mfornet mfornet commented Jul 30, 2026

Copy link
Copy Markdown

This is a patch which I'm using locally due to some newer errors. Everything was written by codex.


Summary

  • ignore the encoding entry when turning problem.statements fields into local statement files
  • ignore non-string statement metadata fields returned by newer Polygon API responses
  • add regression coverage for current metadata and non-UTF-8 statement encodings

Bug

ProblemSession.get_statements_list() currently assumes that every value in each language returned by problem.statements is textual statement content.

Newer Polygon responses can also contain boolean metadata such as:

showCautionsAndGrammaticalFixes: false
showInReview: true

The method passes those booleans to PolygonFile.to_byte(), which calls .encode() and crashes:

AttributeError: 'bool' object has no attribute 'encode'

As a result, commands that enumerate remote files, including polygon-cli update and polygon-cli list, fail for affected problems. The existing loop also incorrectly treats the string-valued encoding metadata as a downloadable encoding.tex statement section.

Fix

Skip encoding and any non-string values before constructing PolygonFile statement entries. Actual statement sections keep using the language's declared encoding, preserving the existing behavior for legacy API responses.

Validation

  • python3 -m unittest discover -s tests -p 'test_*.py' -v
  • live polygon-cli update against a problem containing English and Spanish statements plus the new boolean metadata; the update completed and every tracked file reported Not changed

@mfornet
mfornet marked this pull request as ready for review July 30, 2026 13:53
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