Skip to content

fix(memory): add missing artifact columns to databases created before pin/rename - #3450

Merged
zhayujie merged 1 commit into
zhayujie:masterfrom
Lesereingrape:fix/artifacts-schema-evolution
Oct 3, 2026
Merged

zhayujie merged 1 commit into
zhayujie:masterfrom
Lesereingrape:fix/artifacts-schema-evolution

Conversation

@Lesereingrape

Copy link
Copy Markdown
Contributor

What does this PR do?

74cc1a7f added the pinned_at and title columns by editing _ARTIFACTS_DDL directly, and at the same time removed _ARTIFACTS_ADDED_COLUMNS and its regression test — the ADD-COLUMN path that e9bff3dd had established for exactly this situation, under a comment reading "Evolve the schema by appending here, never by editing the DDL alone".

CREATE TABLE IF NOT EXISTS is a no-op on a table an older release already created, so any database whose artifacts table was built by e9bff3dd keeps the old shape permanently. Setup still succeeds, so _artifacts_ready stays True and record_artifacts() keeps writing rows, while every read of the new columns raises:

cols after init: ['id', 'agent_id', 'session_id', 'turn_seq', 'path', 'kind',
                  'size', 'source', 'created_at', 'updated_at', 'extras']
artifacts_ready: True
LIST RAISED  -> OperationalError no such column: a.pinned_at
PIN RAISED   -> OperationalError no such column: pinned_at
TITLE RAISED -> OperationalError no such column: title

channel/web/api/artifacts.py catches every exception and answers {"status": "error", ...}, so on such an install the artifact center is permanently empty and pin/rename always fail, with no self-repair. Fresh installs happen to look fine, which is why the break does not show up from a clean checkout.

This restores the added-column list (extras, pinned_at, title) and applies it after the DDL, so an existing table gains whatever it lacks.

Type of change

  • Bug fix
  • New feature
  • Docs
  • Refactor / chore

How was it tested?

New regression test test_a_table_from_before_pin_and_title_gained_them creates the pre-pin table shape, opens the store on it, and asserts the columns appear and listing, pinning and renaming all work.

Before the fix it fails, as expected:

tests/test_artifact_index.py:190: AssertionError
assert {'pinned_at', 'title'} <= {'id', 'agent_id', 'session_id', 'turn_seq',
                                  'path', 'kind', 'size', 'source',
                                  'created_at', 'updated_at', 'extras'}

After the fix, measured on Python 3.13 / Windows:

pytest tests/test_artifact_index.py -q   ->  4 failed, 20 passed

The 4 failures are pre-existing on this platform and unrelated (docs\guide.docx vs docs/guide.docx path separators); they fail identically at 74cc1a7f without this change.

The full suite was run on the branch, and then the 17 files those failures came from were re-run with this change reverted:

branch, full suite : 27 failed, 2827 passed, 49 skipped, 55 subtests passed
base, those 17 files: 27 failed,   247 passed,  8 skipped   (the same 27 test ids)

So the failure set is identical at the base; this change turns one failure green and adds none.

ruff check --select F --ignore F403,F405 on both changed files: All checks passed!.

Checklist

Disclosure: this PR was written and tested by an AI agent operating this account; no human has reviewed the diff yet. The "tested locally" box refers to the agent's runs, whose commands and outputs are quoted above.

… pin/rename

The artifacts table evolved in place: pinned_at and title were written into
_ARTIFACTS_DDL while the ADD COLUMN migration path that carried them was
removed. CREATE TABLE IF NOT EXISTS is a no-op on a database an older release
already created, so those databases keep the old shape; _artifacts_ready still
turns True, writes keep landing, and every read of a.pinned_at raises
OperationalError. The artifact view then returns {"status":"error"} forever and
pin/rename can never work.

Restore the added-column list and apply it after the DDL, and cover it with a
test that starts from the pre-pin table shape.
@zhayujie
zhayujie merged commit 0b79645 into zhayujie:master Oct 3, 2026
3 checks passed
@zhayujie

zhayujie commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thanks for the column backfill for databases created before pin/rename — merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

artifact center stays empty after an update: the artifacts table lost its ADD COLUMN migration in 74cc1a7f

2 participants