HPCC-35956 Improve the error reporting when cannot read enough data#21062
HPCC-35956 Improve the error reporting when cannot read enough data#21062ghalliday merged 1 commit intohpcc-systems:candidate-10.0.xfrom
Conversation
|
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-35956 Jirabot Action Result: |
There was a problem hiding this comment.
Pull request overview
This PR updates the low-level row-buffer read-ahead logic in the ECL RTL to provide a clearer runtime error when a caller requests more bytes than are available from the underlying input stream.
Changes:
- Replaces an
assertexpost-check with a conditional that throws a formatted exception when insufficient data remains after attempting to read-ahead. - Adds additional diagnostic details (required bytes, available bytes, offset) to the failure path.
rtl/eclrtl/rtlcommon.hpp
Outdated
| peekBytesDirect(required); | ||
| assertex(required <= maxAvailable()); | ||
| if (unlikely(required > maxAvailable())) | ||
| throw makeStringExceptionV(0, "Required %u bytes, but only %u available (offset %u)", required, (unsigned)maxAvailable(), readOffset); |
There was a problem hiding this comment.
ensureAccessible() now calls makeStringExceptionV(), but rtlcommon.hpp does not include jexcept.hpp (where it is declared). This header is included from other headers (e.g. roxie/ccd/ccdkey.hpp) without jlib.hpp, so this change can break compilation depending on include order. Add the needed include (or switch to an exception helper already declared by the current includes).
rtl/eclrtl/rtlcommon.hpp
Outdated
| peekBytesDirect(required); | ||
| assertex(required <= maxAvailable()); | ||
| if (unlikely(required > maxAvailable())) | ||
| throw makeStringExceptionV(0, "Required %u bytes, but only %u available (offset %u)", required, (unsigned)maxAvailable(), readOffset); |
There was a problem hiding this comment.
The thrown message labels readOffset as just "offset", but readOffset is an offset within the current row, not a file position. Consider clarifying the wording (e.g. "row offset") and/or including the absolute stream position (e.g. tell()+readOffset) to make the error actionable when debugging truncated/corrupt inputs.
| throw makeStringExceptionV(0, "Required %u bytes, but only %u available (offset %u)", required, (unsigned)maxAvailable(), readOffset); | |
| throw makeStringExceptionV(0, "Required %u bytes, but only %u available (row offset %u, absolute stream position %u)", required, (unsigned)maxAvailable(), readOffset, (unsigned)(tell() + readOffset)); |
There was a problem hiding this comment.
I didn't realise the file offset was available! I will change.
dcamper
left a comment
There was a problem hiding this comment.
Looks good, though I think both Copilot suggestions make sense as well.
Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
|
Jirabot Action Result: |
Type of change:
Checklist:
Smoketest:
Testing: