apache/superset · error · SqlLabPermalinkCreateFailedError

Unexpected missing key id

Error message

Unexpected missing key id

What it means

CreateSqlLabPermalinkCommand.run() creates a key-value entry for the permalink, flushes the session, and reads entry.id. If the backend does not populate the primary key after flush (key is None), it raises SqlLabPermalinkCreateFailedError('Unexpected missing key id') (create.py:58). This is an integrity failure of the key-value persistence layer, not a user input error.

Source

Thrown at superset/commands/sql_lab/permalink/create.py:58

    @transaction(
        on_error=partial(
            on_error,
            catches=(
                KeyValueCodecEncodeException,
                KeyValueCreateFailedError,
                SQLAlchemyError,
            ),
            reraise=SqlLabPermalinkCreateFailedError,
        ),
    )
    def run(self) -> str:
        self.validate()
        entry = KeyValueDAO.create_entry(self.resource, self._properties, self.codec)
        db.session.flush()
        key = entry.id
        if key is None:
            raise SqlLabPermalinkCreateFailedError("Unexpected missing key id")
        return encode_permalink_key(key=key, salt=self.salt)

    def validate(self) -> None:
        pass

View on GitHub (pinned to f4587218dd)

Solutions

  1. Run Superset DB migrations ('superset db upgrade') to ensure the key-value tables match the expected schema
  2. Inspect the key_value_entry table: confirm the primary key column exists, is non-null, and is auto-generated for your metadata engine
  3. Check Superset logs for the underlying SQLAlchemy warnings during flush; fix any constraint/PK issues surfaced there
  4. Retry the permalink creation once transient DB issues are ruled out
Defensive patterns

Strategy: try-catch

Try / catch

try:
    CreateSqlLabPermalinkCommand(...).run()
except SqlLabPermalinkCreateFailedError:
    # infrastructure issue: verify KV table schema, run migrations, then retry once
    run_migrations_and_retry_once()

Prevention

When it happens

Trigger: POST /api/v1/sqllab/permalink/ where KeyValueDAO.create_entry succeeds at the Python level but the flushed KeyValueEntry row has no id — e.g. the key-value table schema is missing/drifted so the PK is not generated, or a DB backend that does not auto-populate the PK on flush.

Common situations: The metadata database schema is out of sync (migrations not run after upgrade) so the key_value_entry table lacks proper PK generation; an exotic metadata DB engine or a misconfigured custom KV backend; table corrupted or manually edited.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/8bd99ab089f9094f. Report an issue: GitHub.