Repository navigation
FIX: Store conversation ids up to 128 characters on SQL Server - #4486
Open
Richard Lundeen (richlundeen) wants to merge 2 commits into
Open
Richard Lundeen (richlundeen) wants to merge 2 commits into
Richard Lundeen (richlundeen) wants to merge 2 commits into
Conversation
Conversations.conversation_id and AttackResultEntries.conversation_id were VARCHAR(36), sized for a bare UUID, while PromptMemoryEntries stores 128. SQL Server rejected longer ids, so capability detection failed on every chat target with "supports_multi_turn failed". A new migration widens both columns, and memory now rejects ids no table can store on every backend. Capability detection errors now name the failed check and its cause, and the backend logs each failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Updates bypass conversation ID length validation, creating inconsistent behavior across databases, and SQL Server downgrades leave column lengths incompatible with the previous release’s strict schema check.
2 open issues
What changed in this PR
Fixes SQL Server conversation-ID truncation that blocked GUI capability detection, extending the bounded-column work from #2026 to support free-form IDs.
Changes:
- Widens conversation-ID columns to 128 and adds shared length validation.
- Preserves specific capability-detection errors and logs failures with tracebacks.
- Adds migration, persistence, and diagnostic regression coverage.
| File | Description |
|---|---|
tests/unit/prompt_target/test_discover_target_capabilities.py |
Covers detailed probe failure messages. |
tests/unit/memory/test_conversation_id_length_migration.py |
Covers column lengths, validation, and SQLite migration round trips. |
tests/integration/memory/test_azure_sql_memory_integration.py |
Checks 128-character ID persistence on SQL Server. |
pyrit/prompt_target/common/discover_target_capabilities.py |
Includes failure causes and control-input diagnostics. |
pyrit/memory/memory_models.py |
Shares the 128-character bound and validates constructed entries. |
pyrit/memory/memory_interface.py |
Validates ID lengths before message insertion. |
pyrit/memory/alembic/versions/0d3592c62ad8_widen_conversation_ids.py |
Widens SQL Server columns and updates SQLite declarations. |
pyrit/backend/services/target_service.py |
Logs detection failures with tracebacks. |
Review effort: Balanced
…y id write Address review feedback on the conversation id migration: - The SQL Server downgrade now narrows both columns back to 36 characters, so an earlier release's schema check accepts the database. It refuses when longer ids are stored and re-creates the AttackResultEntries indexes that cover conversation_id, which SQL Server cannot narrow in place. - The SQL Server migration check round-trips the newest migration, so the downgrade runs against a real server in CI. - A SQLAlchemy validator on each entry rejects too-long conversation ids on every assignment, so updates are checked as well as inserts. Ordering tests no longer depend on unique timestamps, which coarse clocks (Windows before Python 3.13) cannot guarantee. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
On SQL Server, the GUI's "detect capabilities" failed on every chat target with
supports_multi_turn failed; capabilities were not changed.The multi-turn probe registers a conversation namedcapability-probe-<uuid>(53 characters), but #2026 sizedConversations.conversation_id(andAttackResultEntries.conversation_id) atVARCHAR(36)for a bare UUID, so SQL Server rejected the insert with "String or binary data would be truncated". SQLite ignores the declared length, which is why tests never caught it. Message pieces already store conversation ids asVARCHAR(128)because they are free-form, not necessarily UUIDs.0d3592c62ad8, which widens both columns to 128 on SQL Server. It drops and re-creates theConversationsprimary key under its original name and clustering, because SQL Server cannot alter a key column in place. On SQLite it updates only the declared types, using SQLite's documented schema edit, so the schema matches the models without rebuildingAttackResultEntriesand its generated analytics column. The downgrade restores 36 characters, so an earlier release's schema check accepts the database. On SQL Server it refuses when longer ids are stored. The SQL Server migration check in CI now round-trips the newest migration, so downgrades run against a real server.CONVERSATION_ID_MAX_LENGTHacross all three tables. A@validateshook on each entry rejects longer ids with aValueErroron every backend, for inserts and updates alike, so SQLite fails the same way SQL Server would.supports_multi_turn failed; capabilities were not changed.supports_multi_turn: Could not prepare the multi-turn probe: ProgrammingError: ... String or binary data would be truncated in table 'Conversations' ...; capabilities were not changed.Control request ['text']: AuthenticationError (HTTP 401): ....Verified on a personal Azure SQL deployment. The migration ran (
3e55dd099e38 -> 0d3592c62ad8), and detection now succeeds on every OpenAI Chat and Responses target, with multi-turn confirmed. Targets that still fail report a specific cause, for exampleModality probe ['image_path', 'text'] failed: NotFoundError (HTTP 404): No endpoints found that support image input.