feat(agents): llm providers v2 migration#2566
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to e665586. Security OverviewDetected Code Changes
|
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 2/5
- There is a high-confidence, high-severity migration risk in
alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py: the per-orgtry/exceptdoes not handle PostgreSQL transaction-abort behavior after a failed statement. - If one org-level
conn.execute()fails, subsequent statements in the same transaction can keep failing (InFailedSqlTransaction), which can cause the backfill to stop or leave data changes incomplete. - Given the concrete failure mode and likely user-visible migration impact, this is high risk to merge until transaction handling is adjusted (e.g., SAVEPOINT/nested transaction strategy).
- Pay close attention to
alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py- per-org error handling currently won’t recover after database-level statement failure.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py">
<violation number="1" location="alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py:563">
P1: The per-org `try/except` won't recover from database-level errors without a SAVEPOINT. In PostgreSQL, a failed statement inside a transaction marks it as aborted — all subsequent `conn.execute()` calls will raise `InFailedSqlTransaction`, causing every remaining org and the preset backfill to fail too.
Wrap each org's work in `conn.begin_nested()` (which emits `SAVEPOINT` / `ROLLBACK TO SAVEPOINT`) so the outer transaction stays healthy after an individual org failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
3bd0de9 to
97ed3cd
Compare
|
@cubic re-review |
@jordan-umusu I have started the AI code review. It will take a few minutes to complete. |
b0407e1 to
c15ed89
Compare
97ed3cd to
3dd2d98
Compare
de58209 to
cb79da3
Compare
3a4f6bc to
dc41893
Compare
cb79da3 to
86cdaf2
Compare
dc41893 to
7c0ff5a
Compare
7c0ff5a to
ac4b173
Compare
ac4b173 to
8a089ef
Compare
daryllimyt
left a comment
There was a problem hiding this comment.
The data migration can fail or backfill incorrect data for supported existing database states, notably duplicate secret environments and pre-existing custom providers.
Full review comments:
-
[P1] Filter provider secrets by environment —
alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py:307-310
When an organization has the same agent credential name in multiple secret environments, this lookup ignoresorganization_secret.environment, so.one_or_none()raises and blocks the whole migration; if only a non-default environment exists, the migration can also copy credentials/grant access that the agent service would not use because runtime lookups default to thedefaultenvironment. Add the environment column and filter these provider-secret queries to the default environment. -
[P1] Do not reuse arbitrary custom providers —
alembic/versions/96470fdcc686_v2_backfill_catalog_and_access.py:436-440
For orgs that already have custom-provider rows when this migration runs, this unscoped lookup either raisesMultipleResultsFoundif there is more than one provider or attaches the legacycustom-model-providercatalog entry to an unrelated existing provider without copying the legacy ciphertext onto that provider. The backfill needs to find a migration-created/provider-specific row or create a dedicated one for the legacy secret.
b1cead5 to
e665586
Compare
Summary by cubic
Backfills orgs into the LLM Providers v2 catalog without decrypting secrets, seeds the platform catalog, and ships a control plane for catalog/custom providers, access, and default model selection. Adds tenant RLS, capability flags, and stricter passthrough to prep broader model management.
New Features
catalog_id.supports_native_streaming,supports_parallel_function_calling) and stricter passthrough validation; tenant RLS enforced; dropped custom-provider discovery status.Migration
organization_secretagent-{provider}-credentialstoencrypted_configon catalog/custom-provider rows (no decryption).tracecat/agent/platform_catalog.json.bedrock,azure_openai,azure_ai,vertex_ai): one org-scoped catalog row (model_name= provider) plus an org-wide access grant.openai,anthropic,gemini): org gets access to all matching platform catalog rows; no org catalog rows.agent_custom_providerand linked catalog row (custom-model-provider/custom) with org-wide access.catalog_idon presets and versions; prefers platform rows over org rows when both match.agent_default_modeltoagent_default_model_catalog_id.Written for commit e665586. Summary will update on new commits. Review in cubic