Repository navigation
FIX: Validate driver-provided fetch sizes - #803
gargsaumya wants to merge 61 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
Treat SQL_NO_DATA as normal completion only after a direct LOB fetch has returned payload. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…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.
| if (indicator < 0) { | ||
| ThrowStdException("Unexpected negative data length"); | ||
| } | ||
| ValidateDecimalDataLength(static_cast<uint64_t>(indicator)); |
There was a problem hiding this comment.
This new decimal length check still accepts an unwritten indicator because indicator starts at 0. A successful driver call that leaves it untouched bypasses both guards; the empty zero-initialized buffer then fails Decimal parsing and is silently converted to None. Initialize it with INVALID_FETCH_INDICATOR, reject the sentinel (and zero for a non-NULL decimal) before parsing, and add missing/zero-indicator tests so malformed driver output cannot become SQL NULL.



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