Skip to content

fix: validate response shape before indexing in test_query_load_exten...#743

Open
BigNounce90 wants to merge 1 commit into
simonw:mainfrom
BigNounce90:BigNounce90-patch-20260521125256
Open

fix: validate response shape before indexing in test_query_load_exten...#743
BigNounce90 wants to merge 1 commit into
simonw:mainfrom
BigNounce90:BigNounce90-patch-20260521125256

Conversation

@BigNounce90
Copy link
Copy Markdown

@BigNounce90 BigNounce90 commented May 21, 2026

Summary

test_query_load_extension called json.loads(result.output)[0] without first checking that the parsed list is non-empty, so any empty or truncated CLI output would raise an IndexError instead of a meaningful assertion failure. The fix extracts the parsed result into a local variable and asserts its length before indexing.

Why it matters

If the CLI silently produces no rows (e.g. due to a regression in the output serialiser or an unexpected empty result set), the test crashes with an opaque IndexError rather than failing with a diagnostic message pointing at the actual assertion.

Testing

The new assert len(rows) == 1 line fires before the index access; all previously-passing inputs still reach and satisfy the original key-shape assertion unchanged.


📚 Documentation preview 📚: https://sqlite-utils--743.org.readthedocs.build/en/743/

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.

1 participant