Merge stable into develop

Merged
FA
2d ago
+6999-947

Supersedes #11701, which has merge conflicts.

Summary

Merges stable at 5a5e13260 into develop at f81744e5a, in two merge commits:

  • 28e1c93f6 merges stable at 186c692eb, the 1.12.3 release.
  • 17f9f7271 merges #11585 (instance label and color global settings), which reached stable while the first merge was tested.

Each merge commit holds its conflict resolution and the changes described below. git show --remerge-diff <merge commit> shows them against the automatic merge.

Conflicts resolved in the merge of the 1.12.3 release

  • backend/infrahub/core/migrations/schema/attribute_kind_update.py, the query that moves the values of an attribute whose kind changes between an indexed kind and TextArea, JSON or List:
    • develop (#11652) groups the attributes by value and looks up each value once. Toward TextArea, JSON or List, it scanned the values without the AttributeValueIndexed label, limited to the values being converted.
    • stable (#11597) gives these values a value_key hash with a RANGE index. It finds or creates them with a MERGE on value_key, value and is_default followed by LIMIT 1, and reads the keys in Python before the query, in a new build_query method.
    • The resolution keeps the grouping of develop. Toward TextArea, JSON or List, each group finds or creates its value with the MERGE of stable, so the scan is gone. The direction toward an indexed kind is the develop version without changes.
    • The build_query override of stable now also passes operation_ats and node_ids, which develop added to the query arguments in #11670 and #11683. Without them, the kind update would ignore the node set and the operation times.
  • backend/infrahub/core/migrations/shared.py: stable moves the construction of each query into build_query, and develop adds operation_ats and node_ids to that construction. build_query passes both.
  • backend/infrahub/core/migrations/query/attribute_add.py: only the imports conflicted. The resolution keeps the imports of both sides.
  • backend/infrahub/core/query/diff.py: develop replaced repeated append calls with extend (42ddb5686), and stable moved the same code into _window_edge_reads (#11709). The resolution keeps _window_edge_reads, written with extend so that it passes the ruff rule FURB113 that develop enforces.
  • frontend/app/src/shared/api/graphql/generated/graphql-cache.d.ts: regenerated with pnpm codegen:graphql and gql.tada 1.11.5 from stable. Only the hash comments change. The generated types are the same as on both branches.

Conflicts resolved in the merge of #11585

  • backend/infrahub/graphql/mutations/preferences.py, in InfrahubSetPreferences.mutate:
    • develop combined the lock and the transaction into one async with statement and removed a # type: ignore[call-arg] that mypy reported as unused.
    • stable (#11585) sets and returns instance_label and instance_color, and keeps the # type: ignore[call-arg] on the return.
    • The resolution keeps the single async with of develop, adds the two fields of stable, and has no type: ignore. mypy reports no error on the file.
  • frontend/app/src/shared/api/graphql/generated/graphql-env.d.ts and graphql-cache.d.ts: regenerated with pnpm codegen:graphql. The regenerated files hold the instance_label and instance_color fields.
  • Regenerating the other generated files changed nothing: schema/schema.graphql, the GraphQL types from pnpm codegen, the REST types from pnpm codegen:openapi, the environment block of docker-compose.yml and the reference docs.

Graph migration 084 of develop renumbered to 085

  • Both branches added a graph migration 084:
    • develop: 084_schema_change_indexes (#11640).
    • stable: 084_index_attribute_value_keys (#11597), released in 1.12.3.
  • A database upgraded to 1.12.3 is at graph version 84, so it would skip any other migration 084. As described in Renumbering a Migration After a Rebase, the migration of stable keeps 084 and the one of develop becomes 085_schema_change_indexes, with minimum_version 84. GRAPH_VERSION is 85.
  • The renumbering also updates the migration's test, dev/knowledge/backend/schema-changes.md and the spec files in dev/specs/ifc-3614-store-schema-changes/.
  • #11597 says that if develop added its own migration 084 first, the migration of stable would need a new number. That was before 1.12.3 shipped it as 084.
  • A database that already ran the migration 084 of develop is at graph version 84, so it does not run 084_index_attribute_value_keys after this merge. It can apply that migration with infrahub db migrate --migration-number 84.

Tests changed by the merge

Git did not flag these.

  • Since #11597, AttributeKindUpdateMigrationQuery requires value_keys. Four tests from develop built the query without them:
    • The three kind update tests of test_migration_selection_count.py read the keys through the migration's build_query, with a new helper build_attribute_kind_update_kwargs in selection_dataset.py.
    • The kind update case of test_migration_node_scope.py runs the migration through execute(), as its relationship removal case does. Its count query gets an empty map of keys, because the count does not read them.
  • test_large_value_lookups_seek_the_key_index (#11597) expected two seeks of the AttributeValue(value_key) index in the kind update query: one to create the missing values and one to link each attribute to its value. The merged query looks up each value once, and the test failed on the merged tree with one seek, so it now expects one seek and still no scan.

Checks run on the merged tree

Run on the second merge commit, which holds both merges:

  • ruff format --check and ruff check on the repository, mypy on backend and ty check: pass.
  • uv run invoke docs.validate: no generated document changed.
  • Frontend: biome ci . (2,031 files), knip, and betterer ci (167 TypeScript issues, the same number as recorded): pass.
  • Frontend tests that #11585 added or changed (vitest run on the preferences, config, navigation, authentication, layout, login, combobox and title tests): 29 files, 186 tests passed.
  • Backend tests that #11585 added or changed (test_50_internals.py, test_preference_repository.py, both test_preferences.py, test_internal.py, test_internal_config_ldap.py, test_instance_settings.py, test_instance_identity.py): 89 passed.

Run on the first merge commit only:

  • pnpm install --frozen-lockfile in frontend/: the merged lockfile matches the merged package files.
  • Unit tests in backend/tests/unit/core/graph and backend/tests/unit/core/migrations: 81 passed.
  • Component tests on Neo4j for the kind update, the value keys and the migrations: 155 passed and 10 expected failures (xfail), in test_attribute_value_key.py, test_attribute_kind_update.py, test_migration_selection_count.py, test_migration_node_scope.py, test_migration_second_run.py, test_all_migrations_rollback.py, test_084_index_attribute_value_keys.py and test_085_schema_change_indexes.py.
  • Component tests on Neo4j with 3 workers, in backend/tests/component/core/migrations, core/diff, core/constraint_validators, core/graph, core/schema_change, core/test_attribute_value_key.py, core/test_branch_rebase.py and message_bus/operations/requests/test_proposed_change.py: 1,311 passed, 12 skipped, 11 expected failures (xfail) and 1 failure.
    • The failure: test_kind_migration.py::test_calculate_with_migrated_kind_node found no human_friendly_id change in the base branch diff of the migrated car.
    • The same test passed when run alone, with its whole module (13 passed), after the module that ran before it on the same worker (14 passed), and 30 times out of 30 in 3 parallel sessions of 10 runs. The cause of the single failure is not known.

Not run locally: the rest of the backend component suite, the integration, functional and e2e tests, the rest of the frontend tests, and markdownlint (not installed in this environment). The Markdown edits only replace 084 with 085 and 84 with 85.