﻿# ENTITY_MODEL_MISMATCH — a write disagreed with an entitys fixed model

An entitys model is fixed at creation: its model name and model version never change for the life of the entity ID, including across delete and recreate.…

<em>cyoda-go version <a href="https://github.com/Cyoda/cyoda-go/releases/tag/v0.9.0">0.9.0</a></em>

# errors.ENTITY_MODEL_MISMATCH

## NAME

ENTITY_MODEL_MISMATCH — a write named an entity ID that already exists under a different model name or model version.

## SYNOPSIS

HTTP: `400` `Bad Request`. Retryable: `no`.

## DESCRIPTION

An entity's model is fixed at creation: its model name and model version never change for the life of the entity ID, including across delete and recreate. A soft-deleted entity keeps its row and its history under that same model, so recreating it under a different model would be exactly the rewrite this invariant forbids. Every storage backend enforces this at the point of write and reports this code rather than silently rewriting which model the entity's history belongs to — the stored model always wins.

Allowing the rewrite would strand the entity's earlier-model version history: every point-in-time read issued under the original model would lose the entity entirely, with no error, the moment a later write moved it to a new model. That is the defect this code exists to prevent.

**This code is not a documented client-facing outcome of any current request.** No HTTP endpoint or gRPC request accepts a model on an entity update — creating an entity always mints a fresh entity ID, and updating one always targets the model the entity already has. There is today no way for an ordinary client request to disagree with an entity's own model, so this code should never appear in a real response.

If you see it anyway, that means some write path — a new endpoint, an internal job, a migration, direct storage-layer access — is constructing a write with a model different from the target entity's. **That is a defect to report** (with the entity ID from the `entityId` property and the request that produced it), not a condition for the caller to work around. The `entityId` property in the problem-detail body identifies the entity whose model the write disagreed with.

## RECOVERY

There is no client-side recovery: no legitimate request should ever produce this response. Report it as a bug, including the `entityId` and the operation that triggered it, so the write path responsible for supplying the wrong model can be identified and fixed.

## SEE ALSO

- errors
- errors.ENTITY_NOT_FOUND
- errors.ENTITY_MODIFIED

## See also

- [`cyoda help errors`](/help/errors/) — Every error response from the Cyoda REST API carries a structured `errorCode` in the `properties` object. Multiple codes may share the same HTTP status. Programmatic handling keys on `errorCode`, not HTTP status.
- [`cyoda help errors ENTITY_NOT_FOUND`](/help/errors/entity_not_found/) — No entity with the given ID exists in the tenant's data store, or the entity existed at a point-in-time that precedes the requested snapshot. Also returned for audit log lookups when the specified event or message cannot be found.
- [`cyoda help errors ENTITY_MODIFIED`](/help/errors/entity_modified/) — When an entity update request carries an `If-Match` header, the header states the version the request starts from. The server checks it once, when the request's transition starts: the supplied transaction ID must equal the entity's `meta.transactionId` as the request's transaction reads it. A mismatch means another writer has updated the entity since the caller's last read. The optimistic-concurrency guard rejects the update rather than silently overwrite.

## Raw formats

- [`/help/errors/entity_model_mismatch.json`](/help/errors/entity_model_mismatch.json) — full descriptor (matches `GET /help/{topic}` envelope)
- [`/help/errors/entity_model_mismatch.md`](/help/errors/entity_model_mismatch.md) — body only