Repository navigation
Conversation
`pandas.set_option("display.max_colwidth", -1)` was executed before the
try block. Since pandas 1.0 a negative value is rejected with
`ValueError: Value must be a nonnegative integer or None`, so the handler
raised on every single invocation and the module was effectively dead
(reproduced with pandas 2.3.3).
Pass `None`, the modern spelling of "unlimited", and move the call inside
the guarded block so any future pandas change degrades to the module's
error dict instead of an unhandled exception.
Adds tests/test_xlsx_enrich.py covering the handler round-trip on a
generated .xlsx attachment.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012VxctWivKrfQWn8tVD8qkT
This branch has not been deployed
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.
BLUF —
xlsx_enrichfailed every query because modern pandas rejects adisplay.max_colwidthof-1.xlsx_enrich.pycalledpandas.set_option("display.max_colwidth", -1), which modern pandas rejects withValueError, and the call sat outside the handler'stryblock so nothing caught it. Every query against the module failed beforeread_excel()was reached, returning neither a result nor a MISP error.None, the current spelling of unlimited width, and moves the call inside thetryblock, with regression tests.misperrorsdict.Problem
misp_modules/modules/expansion/xlsx_enrich.py, line 46 (before this change) called:Modern pandas rejects a negative value for that option and raises
ValueError: Value must be a nonnegative integer or None(reproduced with pandas 2.3.3).Because the call sat outside the surrounding
tryblock, the exception was not caught bythe module's error handling and propagated out of
handler().Concrete trigger: any query at all against this module — e.g. a
attachmentquery with avalid base64-encoded
.xlsxindata. The first statement after decoding the attachmentraises, so the module never reaches
pandas.read_excel()and returns no result and noMISP error dict.
Fix
Noneinstead of-1.Noneis the current pandas spelling of "unlimited columnwidth" and preserves the original intent of the code.
set_option()call inside the existingtryblock, so that any future pandaschange here degrades into the module's normal
misperrorserror dict rather than anunhandled exception. This matches how the rest of the pandas work in this handler
(
read_excel,to_string) is already guarded.The change is two lines and does not alter the module's output format.
Testing
Gate command:
poetry run pytest(the same invocation used by the repo's.github/workflows/test-package.yml).Result:
106 passed, 5 subtests passed in 89.81s (0:01:29).Regression coverage added in
tests/test_xlsx_enrich.py:TestXlsxEnrich::test_handler_extracts_text_from_xlsx— builds an in-memory.xlsxattachment, runs
handler(), and asserts the cell contents come back in the freetextresult. This fails with the old
-1value.TestXlsxEnrich::test_handler_sets_unlimited_column_width— assertsdisplay.max_colwidthends up asNone, pinning the intended "unlimited" behaviour.🤖 Generated with Claude Code