Repository navigation
FIX: Validate driver-provided fetch sizes - #803
gargsaumya wants to merge 63 commits into
Conversation
…nto saumya/native-fetch-validation
…nto saumya/native-fetch-validation # Conflicts: # mssql_python/pybind/ddbc_bindings.cpp
…nto saumya/native-fetch-validation # Conflicts: # mssql_python/pybind/ddbc_bindings.cpp
Gaurav Sharma (bewithgaurav)
left a comment
There was a problem hiding this comment.
the driver-provided size validation is well scoped and the normal fetch and arrow paths hold up. I found one suggestion worth incorporating before merge, so requesting changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Successful zero-row fetches can loop indefinitely, and malformed indicators or the global test hook can cause resource and concurrency problems.
Review effort: Balanced
Findings: 2
Open (4)
What changed in this PR
Adds defensive validation for driver-provided fetch metadata in the native ODBC layer.
Changes:
- Validates row counts, indicators, wide-character lengths, and Arrow bounds.
- Hardens streamed variable-length fetching and buffer growth.
- Adds native regression scenarios and subprocess coverage.
| File | Description |
|---|---|
mssql_python/pybind/ddbc_bindings.cpp |
Implements fetch validation and test hooks. |
mssql_python/pybind/ddbc_bindings.h |
Rejects malformed wide-character lengths. |
tests/test_010_pybind_functions.py |
Tests malformed driver responses and streaming progress. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nto copilot/pr803-rebased
…crosoft/mssql-python into copilot/pr803-rebased
…crosoft/mssql-python into copilot/pr803-rebased
…crosoft/mssql-python into copilot/pr803-rebased
Seed direct and bound fetch indicators with invalid sentinels so omitted driver writes cannot expose empty or stale data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…crosoft/mssql-python into copilot/pr803-rebased
Seed every direct SQLGetData output with the invalid indicator sentinel before driver calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…crosoft/mssql-python into copilot/pr803-rebased
Reject unreadable truncation diagnostics, missing variant probe indicators, and SQL_NO_TOTAL for fixed-width columns. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sumit Sarabhai (sumitmsft)
left a comment
There was a problem hiding this comment.
Reviewed the exact current head for correctness, native safety, data integrity, diagnostics, cleanup, Arrow/LOB bounds, test coverage, and the applicable ODBC length/indicator contract.
One Medium-severity issue remains: the directly changed DECIMAL/NUMERIC fetch path can accept an unwritten driver indicator and silently expose malformed non-NULL output as Python None. The remaining reviewed fetch paths had no actionable findings.
Recommendation: Request changes.
|
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
Sumit Sarabhai (sumitmsft)
left a comment
There was a problem hiding this comment.
The bound-row decimal path still bypasses the new malformed-indicator validation for zero and SQL_NO_TOTAL, allowing invalid metadata to be exposed as SQL NULL semantics. Please address the inline finding before merging.
| case SQL_NUMERIC: { | ||
| try { | ||
| SQLLEN decimalDataLen = buffers.indicators[col - 1][i]; | ||
| ValidateDecimalDataLength(decimalDataLen); |
There was a problem hiding this comment.
The changed decimal validator is bypassed for both zero and SQL_NO_TOTAL in the bound row path. ValidateBoundFetchIndicator permits these values for decimal because fixedValueSize is 0, then the generic special-value branches above this switch append None and continue, so ValidateDecimalDataLength never runs. The new helper test calls the validator directly and misses the production caller. Please route bound DECIMAL/NUMERIC zero and SQL_NO_TOTAL indicators through the decimal validator before the generic fallbacks, and add a ConvertBufferedRows regression so malformed numeric metadata cannot become SQL NULL.


Work Item / Issue Reference
Summary
Stacked on #802 so this review contains only driver-provided fetch validation.