Skip to content

feat: mirror solution writes into artefact.attributes (write-both) [2/3] - #849

Open
almeidaraul wants to merge 1 commit into
TO-404/1-add-attributesfrom
TO-404/2-write-both
Open

feat: mirror solution writes into artefact.attributes (write-both) [2/3]#849
almeidaraul wants to merge 1 commit into
TO-404/1-add-attributesfrom
TO-404/2-write-both

Conversation

@almeidaraul

Copy link
Copy Markdown
Contributor

Part 2 of 3 (stacked). Base: TO-404/1-add-attributes (#848).

What

Write-both step: the controllers now write to both the legacy solution-specific fields and the new attributes field, so a later release can switch reads over safely.

  • Starting a solution test still populates track / source / stage / bundled_builds_hash and now also mirrors {track, source} into attributes.
  • PATCHing bundled_builds still updates the legacy relationship/hash and now mirrors {bundled_builds, bundled_builds_hash} into attributes (cleared when bundled_builds is emptied).

Safety

Reads are unchanged and the API request/response contract is untouched (OpenAPI schema is identical), so this is a no-op for existing clients and safe during a rolling upgrade.

Review note

Review only against the base branch (#848). Merge/deploy after #848.

Second step of the expand/contract migration to a generic `attributes`
field. The controllers now write to BOTH the legacy solution-specific fields
and `attributes`, so a later release can switch reads over safely:

- Starting a solution test still populates track/source/stage/
  bundled_builds_hash and now also mirrors {track, source} into attributes.
- PATCHing bundled_builds still updates the legacy relationship/hash and now
  mirrors {bundled_builds, bundled_builds_hash} into attributes (cleared when
  bundled_builds is emptied).

Reads are unchanged and the API request/response contract is untouched, so
this is a no-op for existing clients and safe during a rolling upgrade.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@almeidaraul
almeidaraul marked this pull request as ready for review August 18, 2026 13:29
Copilot AI lite review requested due to automatic review settings August 18, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the “write-both” step for migrating solution-specific artefact data into the new generic artefact.attributes JSONB field, while keeping existing reads and the API contract unchanged for rolling-upgrade safety.

Changes:

  • When starting a solution test execution, mirror {track, source} into artefact.attributes in addition to the legacy columns.
  • When PATCHing bundled_builds, mirror {bundled_builds, bundled_builds_hash} into artefact.attributes, and remove those mirrored keys when clearing bundled builds.
  • Add/extend controller tests to cover the write-both mirroring behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
backend/test_observer/controllers/test_executions/start_test.py Mirrors solution identity (track, source) into artefact.attributes during artefact creation for solution test starts.
backend/test_observer/controllers/artefacts/artefacts.py Mirrors bundled build IDs/hash into artefact.attributes when bundled_builds is patched/cleared.
backend/tests/controllers/test_executions/test_start_test.py Adds a test asserting solution start writes both legacy fields and attributes.
backend/tests/controllers/artefacts/test_artefacts.py Extends PATCH bundled builds tests to assert mirroring/clearing behavior for attributes.
Suppressed comments (1)

backend/tests/controllers/artefacts/test_artefacts.py:1661

  • Clearing bundled_builds should remove the mirrored keys, but it shouldn’t require the entire attributes object to be empty (other keys may legitimately remain). This assertion will fail if any other attributes are present.
    assert response.status_code == 200
    assert response.json()["attributes"] == {}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}
}

self.artefact = get_or_create(self.db, Artefact, filter_kwargs=filter_kwargs, creation_kwargs=creation_kwargs)
Comment on lines +1619 to +1623
expected_ids = sorted([build1.id, build2.id])
assert data["attributes"] == {
"bundled_builds": expected_ids,
"bundled_builds_hash": calculate_bundled_builds_hash(expected_ids),
}
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.

2 participants