unslothai/unsloth · warning · HTTPException

No fields to update

Error message

No fields to update

What it means

A 400 from PUT /api/providers/{provider_id}: the payload contained none of the updatable fields — no metadata fields (display_name, base_url, is_enabled, models, available_models, max_output_tokens), no encrypted_api_key, and no clear_api_key. The endpoint refuses no-op updates so callers notice malformed payloads instead of silently succeeding.

Source

Thrown at studio/backend/routes/providers.py:356

            if metadata_requested:
                try:
                    providers_db.update_provider(
                        id = provider_id,
                        display_name = existing["display_name"],
                        base_url = existing["base_url"],
                        is_enabled = bool(existing["is_enabled"]),
                        models = existing.get("models") or [],
                        available_models = existing.get("available_models") or [],
                        max_output_tokens = existing.get("max_output_tokens"),
                    )
                except Exception:
                    logger.exception(
                        "provider.update_metadata_rollback_failed", provider_id = provider_id
                    )
            raise

    if not metadata_requested and not payload.encrypted_api_key and not payload.clear_api_key:
        raise HTTPException(status_code = 400, detail = "No fields to update")

    row = providers_db.get_provider(provider_id)
    return _provider_response(row)


@router.put("/{provider_id}/api-key/migrate", response_model = ProviderResponse)
async def migrate_provider_api_key(
    provider_id: str,
    payload: ProviderCredentialMigration,
    credential: tuple = Depends(get_current_credential),
    via_api_key: bool = Depends(authenticated_via_api_key),
):
    """Insert a browser legacy key only when this provider has no saved key."""
    require_ui_session(via_api_key)
    if providers_db.get_provider(provider_id) is None:
        raise HTTPException(status_code = 404, detail = "Provider not found")
    api_key = resolve_provider_api_key_or_400(
        None, payload.encrypted_api_key, allow_saved_key = False

View on GitHub (pinned to 203007d190)

Solutions

  1. Include at least one field you intend to change, e.g. display_name.
  2. In diff-based clients, skip the PUT when the computed change set is empty.
  3. Verify field names against ProviderUpdate — unknown keys are ignored and can leave the body effectively empty.

Example fix

// before
const body = diff(left, right); // {} when nothing changed
await putProvider(id, body);
// after
const body = diff(left, right);
if (Object.keys(body).length === 0) return; // nothing to save
await putProvider(id, body);
Defensive patterns

Strategy: validation

Validate before calling

const UPDATABLE = ["display_name", "base_url", "is_enabled", "models", "available_models", "max_output_tokens", "encrypted_api_key", "clear_api_key"];
const hasUpdate = UPDATABLE.some(f => f in body);
if (!hasUpdate) throw new Error("PUT body contains no updatable fields");

Prevention

When it happens

Trigger: PUT with an empty JSON body {}; a client that builds the diff body conditionally and ends up with zero keys; serialization bugs dropping all fields before send.

Common situations: Diff-based update code where nothing changed; DTO field names not matching the API schema (silently ignored); a 'save' button firing with an untouched form represented as {}.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/429ad511946bbb7b. Report an issue: GitHub.