apache/superset · error · KeyValueUpdateFailedError
An error occurred while updating the value.
Error message
An error occurred while updating the value.
What it means
Raised by KeyValueDAO.update_entry when KeyValueDAO.get_entry(resource, key) returns no row, meaning there is no existing KeyValueEntry to mutate. Update is deliberately strict: unlike upsert_entry, it never creates the missing entry. The error class derives from UpdateFailedError and maps to a generic 'update failed' HTTP response, so the real signal is that the key does not exist under that resource.
Source
Thrown at superset/daos/key_value.py:177
def update_entry(
resource: KeyValueResource,
value: Any,
codec: KeyValueCodec,
key: Key,
expires_on: datetime | None = None,
) -> KeyValueEntry:
"""
Update an existing entry, raising ``KeyValueUpdateFailedError`` if no entry
exists for the given key.
"""
if entry := KeyValueDAO.get_entry(resource, key):
entry.value = codec.encode(value)
entry.expires_on = expires_on
entry.changed_on = datetime.now()
entry.changed_by_fk = get_user_id()
return entry
raise KeyValueUpdateFailedError()
View on GitHub (pinned to f4587218dd)
Solutions
- Ensure create_entry (or upsert_entry) ran successfully for that exact resource+key before calling update_entry.
- If create-or-update semantics are intended, call upsert_entry instead of update_entry.
- Double-check the KeyValueResource enum value matches the one used on creation.
- Catch the error and fall back to create_entry when the entry is genuinely absent.
Example fix
# before
KeyValueDAO.update_entry(resource, value, codec, key=entry_key) # entry missing -> KeyValueUpdateFailedError
# after
from superset.daos.key_value import KeyValueDAO
from superset.key_value.commands.exceptions import KeyValueUpdateFailedError
try:
KeyValueDAO.update_entry(resource, value, codec, key=entry_key)
except KeyValueUpdateFailedError:
KeyValueDAO.create_entry(resource, value, codec, key=entry_key) # or upsert_entry Defensive patterns
Strategy: try-catch
Validate before calling
# prefer get_entry existence check, or just use upsert semantics
entry = KeyValueDAO.get_entry(resource, key)
if entry is None:
KeyValueDAO.create_entry(resource, value, codec, key=key)
else:
KeyValueDAO.update_entry(resource, value, codec, key=key) Try / catch
from superset.key_value.commands.exceptions import KeyValueUpdateFailedError
try:
KeyValueDAO.update_entry(resource, value, codec, key=key)
except KeyValueUpdateFailedError:
KeyValueDAO.create_entry(resource, value, codec, key=key) # entry absent -> create Prevention
- Use upsert_entry when create-or-update semantics are acceptable.
- Ensure the create step of a flow commits before issuing updates.
- Keep the KeyValueResource enum value consistent between create and update call sites.
When it happens
Trigger: Calling update_entry with a key that was never created or has been deleted; updating an expired entry that a prior purge removed; using the right key under the wrong KeyValueResource enum value (resources partition the namespace); a UUID vs int key mismatch with how the entry was created.
Common situations: Two-step flows where the client 'updates' a tab/dashboard state before the initial create succeeds; background workers racing with expiration cleanup; environment resets (metadata DB wiped) while browsers hold old keys in local state.
Related errors
- Annotation not found.
- Annotation layer not found.
- Annotation layer not found.
- Chart not found.
- CSS template not found.
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/70eddc6d91f8ca88.
Report an issue: GitHub.