diegosouzapw/OmniRoute · error

Refusing to persist quotaWindowThresholds with rejected keys

Error message

Refusing to persist quotaWindowThresholds with rejected keys: ${result.rejected.join(", ")}

What it means

In createProviderConnection, sanitizeQuotaWindowThresholds rejected one or more model keys in the provided quotaWindowThresholds map; persisting the row would store unrecognized/invalid keys, so the whole creation is refused rather than silently dropping data, keeping the in-memory object and the SQLite row consistent.

Solutions

  1. Remove or fix the rejected model keys listed in the message before retrying
  2. Use the model identifiers as known to the provider when setting window thresholds
  3. Validate thresholds in the API/dashboard layer before submitting the connection
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/db/providers.ts:673 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/779c4bd5a586d362. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/db/providers.ts:673

    "healthCheckInterval",
  ];
  for (const field of optionalFields) {
    if (data[field] !== undefined && data[field] !== null) {
      connection[field] = data[field];
    }
  }
  if (normalizedProviderSpecificData && Object.keys(normalizedProviderSpecificData).length > 0) {
    connection.providerSpecificData = normalizedProviderSpecificData;
  }
  // Sanitize the window-thresholds map up front so the in-memory `connection`
  // matches the row we're about to insert. The serialize path runs the same
  // sanitizer on the way to SQLite. Assigning null (when sanitize collapses
  // to no-overrides) keeps the field present on the returned object so the
  // UI can tell "field was read, no overrides" apart from "field absent."
  if ("quotaWindowThresholds" in connection) {
    const result = sanitizeQuotaWindowThresholds(connection.quotaWindowThresholds);
    if (result.rejected.length > 0) {
      throw new Error(
        `Refusing to persist quotaWindowThresholds with rejected keys: ${result.rejected.join(", ")}`
      );
    }
    connection.quotaWindowThresholds = result.sanitized;
  }

  // Same sanitization for rateLimitOverrides — keep in-memory representation
  // in sync with what gets persisted. Reject (don't silently drop) invalid
  // keys/values so a direct DB writer can't lose operator intent.
  if ("rateLimitOverrides" in connection) {
    const result = sanitizeRateLimitOverrides(connection.rateLimitOverrides);
    if (result.rejected.length > 0) {
      throw new Error(
        `Refusing to persist rateLimitOverrides with rejected keys: ${result.rejected.join(", ")}`
      );
    }
    connection.rateLimitOverrides = result.sanitized;
  }

View on GitHub (pinned to a179ffed5b)