BerriAI/litellm · error · ValueError

op must be add, remove, or replace

Error message

op must be add, remove, or replace

What it means

Pydantic before-validator on SCIMPatchOperation.op: the SCIM PATCH operation string (after lowercasing) is not one of add/remove/replace. SCIM v2 only defines those three ops, so anything else is rejected before normalization returns.

Solutions

  1. Use op value 'add', 'remove', or 'replace' per SCIM patch semantics.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/types/proxy/management_endpoints/scim_v2.py:174 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/c003e93b2dd4e75e. Report an issue: GitHub.

Appendix: source

Thrown at litellm/types/proxy/management_endpoints/scim_v2.py:174

    totalResults: int
    startIndex: int | None = 1
    itemsPerPage: int | None = 10
    Resources: list[SCIMUser] | list[SCIMGroup]


# SCIM PATCH Operation Models
class SCIMPatchOperation(BaseModel):
    op: str
    path: str | None = None
    value: Any | None = None

    @field_validator("op", mode="before")
    @classmethod
    def normalize_op(cls, v):
        if isinstance(v, str):
            v_lower: Final = v.lower()
            if v_lower not in {"add", "remove", "replace"}:
                raise ValueError("op must be add, remove, or replace")
            return v_lower
        return v


class SCIMPatchOp(BaseModel):
    schemas: list[str] = ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
    Operations: list[SCIMPatchOperation]


# SCIM Service Provider Configuration Models
class SCIMFeature(BaseModel):
    supported: bool
    maxOperations: int | None = None
    maxPayloadSize: int | None = None
    maxResults: int | None = None


class SCIMServiceProviderConfig(BaseModel):

View on GitHub (pinned to 77b7c6c40c)