Skip to content

fix(den-api): reject duplicate model IDs on custom providers and deduplicate models.dev IDs case-insensitively - #7078

Open
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix-llm-provider-duplicate-model-ids
Open

sentry[bot] wants to merge 1 commit into
devfrom
seer/fix-llm-provider-duplicate-model-ids

Conversation

@sentry

@sentry sentry Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What is this about?

What problem does it solve?

Duplicate model IDs caused a unique constraint violation on (llm_provider_id, model_id) (llm_provider_model_provider_model) during the batch insert. Duplicates included identical IDs in an array, several map keys with the same explicit id, and IDs that differed only by whitespace or case. The result was an unhandled 500.

What was the situation before?

PATCH /v1/llm-providers/:llmProviderId deletes existing llm_provider_model rows and inserts new ones for each entry in normalized.models. Any duplicate in that list failed the insert.

How is this implemented?

  • normalizeCustomProviderConfig (ee/apps/den-api/src/llm/custom-provider.ts) checks that all normalized model IDs are unique, ignoring case and whitespace. Duplicates throw CustomProviderConfigError.
  • normalizeLlmProviderInput (ee/apps/den-api/src/routes/org/llm-providers.ts) catches that error and returns 400 Bad Request (invalid_custom_provider_config).
  • normalizeLlmProviderInput also deduplicates modelIds for models_dev providers, case-insensitively, keeping first occurrences.
  • Unit tests in ee/apps/den-api/test/llm-provider-custom-config.test.ts cover duplicate IDs in arrays, mapped configs, and case/whitespace variations.

What else changed?

none

Release note

Updating an LLM provider with duplicate model IDs now returns a clear 400 error instead of a server error.

Evidence

  • Before: duplicate model IDs in a custom provider config caused a 500 on PATCH /v1/llm-providers/:llmProviderId. After: the request returns 400 invalid_custom_provider_config.
  • Unit tests added in llm-provider-custom-config.test.ts for array duplicates, mapped configs, and case/whitespace variants.

Fixes DEN-API-42

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry at no cost. You can adjust this setting at any time.

@vercel
vercel Bot temporarily deployed to Preview – openwork-app November 5, 2026 23:10 Inactive
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Nov 5, 2026 11:10pm UTC
openwork-den Skipped Skipped Nov 5, 2026 11:10pm UTC
openwork-diagnostics Skipped Skipped Nov 5, 2026 11:10pm UTC
openwork-landing Skipped Skipped v0 Nov 5, 2026 11:10pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – openwork-den November 5, 2026 23:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing November 5, 2026 23:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics November 5, 2026 23:10 Inactive
@diff-warden

diff-warden Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Warden: advisory — no major findings

No high or medium security findings and no confidentiality findings.

Warden does not block merging or grant or withdraw approvals. Tests and human review remain separate requirements.

Reviewed b0d8c869a09b · Warden run · Updates after every Warden run.

This branch was previously deployed

4 inactive deployments
Preview – openwork-den — b0d8c869 Deployed Nov 5, 2026 by vercel[bot]
Preview – openwork-diagnostics — b0d8c869 Deployed Nov 5, 2026 by vercel[bot]
Preview – openwork-landing — b0d8c869 Deployed Nov 5, 2026 by vercel[bot]
Preview – openwork-app — b0d8c869 Deployed Nov 5, 2026 by vercel[bot]
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.

0 participants