Fix ValueError in TraceParser when parameter value contains ' = '#9
Open
fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
Open
Fix ValueError in TraceParser when parameter value contains ' = '#9fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
Conversation
TraceParser._parse_parameters_block called line.split(' = ') without
maxsplit. A parameter value that itself contains the substring ' = '
(legitimate -- a varchar column can carry arbitrary text including
key=value-shaped strings) splits into 3+ parts and the unpacking
'_, param_def = ...' raises:
ValueError: too many values to unpack (expected 2, got N)
The enclosing trace block is then dropped silently, affecting every
event that carries parameters or function-return values.
Fix: pass maxsplit=1. The second ' = ' (and any after) stays inside
the value, where it belongs. Add regression test
test_68_param_value_containing_equals exercising a varchar parameter
whose value contains two ' = ' substrings.
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.
Summary
TraceParser._parse_parameters_block(insrc/firebird/lib/trace.py) callsline.split(' = ')without amaxsplitargument. When a parameter line's value itself contains the substring=— entirely legal, since avarcharcolumn can carry arbitrary text, including key=value-shaped strings — the split yields 3+ parts and the unpacking on the same line raises:Because
_parse_parameters_blockis called from_parse_parametersand from__parser_func_finish(thereturns:block of function-finish events), the failure silently drops the enclosing trace block on every event that carries parameters or function-return values. The error propagates out ofparse_event, but typical streaming consumers swallow it per-block, and one bad row eats real telemetry.Repro
A trace block with a parameter whose value contains
=, e.g.param0 = varchar(80), \"alpha = 1; beta = 2\", triggers the ValueError before the fix. Added astest_68_param_value_containing_equalsintests/test_trace.py; without the patch, the new test fails at line 1386 withValueError: too many values to unpack (expected 2, got 4). With the patch, all 21 tests intest_trace.pypass.Fix
One-character change:
line.split(' = ', maxsplit=1). The second=(and any after) stays inside the value, where it belongs. The expected(name, value)shape of the unpacking is preserved.Both call sites of
_parse_parameters_block(in_parse_parametersat line ~1390 and in__parser_func_finishat line ~1755) inherit the fix.Out of scope
Multi-line parameter values that span multiple
__current_blockentries (line continuation) are a separate parsing concern and are not addressed here.Test plan
pytest tests/test_trace.pypasses (21/21) with the fix applied.test_68_param_value_containing_equalsto fail with the expectedValueErrorat the patched line.