Skip to content

FIX: name SQLite result codes on analytics OperationalErrors (P311-21) - #3893

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Sainath-Reddy7:p311-21/sqlite-errorname
Nov 4, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Sainath-Reddy7:p311-21/sqlite-errorname

Conversation

@Sainath-Reddy7

Copy link
Copy Markdown
Contributor

Resolves the P311-21 reservation in #3166 with option (b) from the question there — delivered within the reservation window since the steer hadn't arrived by Nov 4.

Description

The recorded survey found no error-message matching left to replace, so per that question this adds the item's literal ...codes/names half: non-plain-SQLITE_BUSY OperationalErrors propagated from the analytics retry loop and session now carry an add_note naming the structured result code, built from the stdlib sqlite3 constants:

  • stale snapshot → sqlite result code 517 (SQLITE_BUSY_SNAPSHOT)
  • plain lock → sqlite result code 6 (SQLITE_LOCKED) … etc.

Same "database is locked" text, now distinguishable in the formatted traceback — using the add_note idiom this codebase established in P311-08.

Scope discipline: notes only. Exception types, messages, the retry decision, the timeout conversion, and non-SQLite (mssql) OperationalErrors are unchanged — the non-SQLite path attaches nothing.

Verification (commands and outputs)

Full analytics memory suite:

$ python -m pytest tests/unit/memory/test_attack_analytics.py -q
203 passed, 59 warnings in 19.41s

Three new regression tests: the named re-raise (asserts the exact 517 (SQLITE_BUSY_SNAPSHOT) note), the note-free non-SQLite re-raise, and unchanged plain-BUSY retry-to-success. An intermediate control-flow slip (my own) that converted every OperationalError into a timeout was caught by the suite and fixed before this push — the full file passes.

Agent disclosure: prepared with an AI coding agent (ZCode) at the direction of the submitting account owner; the survey, this implementation and the test run were reviewed by them.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Sainath-Reddy7

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

…P311-21)

Non-busy SQLite failures re-raised from the analytics retry loop and
session no longer read identically: an add_note built from the stdlib
sqlite3 result-code constants surfaces e.g. 'sqlite result code 517
(SQLITE_BUSY_SNAPSHOT)' for stale snapshots vs plain locks. Notes only —
exception types, messages, retry decisions and the timeout conversion
are unchanged; non-SQLite OperationalErrors pass through untouched.

Three regression tests cover the named re-raise, the note-free
non-SQLite path, and unchanged plain-BUSY retry behavior.
Use sqlite_errorname instead of overlapping SQLite constants, deduplicate propagated notes, and keep non-SQLite sessions unchanged. Cover real-driver errors and exception identity.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) merged commit 2020789 into microsoft:main Nov 4, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants