Skip to content

Commit ba203d3

Browse files
authored
fix schema integrity check to remove resolved violations (#7279)
* run integrity check updated even if no conflicts * add changelog
1 parent badc4d3 commit ba203d3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

backend/infrahub/proposed_change/tasks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,6 @@ async def run_proposed_change_schema_integrity_check(model: RequestProposedChang
441441
)
442442
)
443443

444-
if not conflicts:
445-
return
446-
447444
database = await get_database()
448445
async with database.start_transaction() as db:
449446
object_conflict_validator_recorder = ObjectConflictValidatorRecorder(

backend/tests/unit/message_bus/operations/requests/test_proposed_change.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from infrahub.core.constants import DiffAction, InfrahubKind, SchemaPathType
1111
from infrahub.core.diff.model.diff import DiffElementType
1212
from infrahub.core.initialization import create_branch
13+
from infrahub.core.manager import NodeManager
1314
from infrahub.core.node import Node
1415
from infrahub.core.validators.enum import ConstraintIdentifier
1516
from infrahub.database import InfrahubDatabase
@@ -282,6 +283,7 @@ async def test_schema_integrity(
282283
person = await Node.init(db=db, schema="TestPerson", branch=branch2)
283284
await person.new(db=db, name="ALFRED", height=160, cars=[car_accord_main.id])
284285
await person.save(db=db)
286+
person_john = await NodeManager.get_one(db=db, branch=branch2, id=person_john_main.id)
285287

286288
branch2_schema = registry.schema.get_schema_branch(name=branch2.name)
287289
person_schema = branch2_schema.get(name="TestPerson")
@@ -329,3 +331,14 @@ async def test_schema_integrity(
329331
),
330332
}
331333
] in all_conflicts
334+
335+
# verify integrity checks are removed after being fixed
336+
person_john.name.value = "JOHN"
337+
await person_john.save(db=db)
338+
339+
await run_proposed_change_schema_integrity_check(model=schema_integrity_01)
340+
341+
checks = await registry.manager.query(db=db, schema=InfrahubKind.SCHEMACHECK)
342+
assert len(checks) == 1
343+
assert checks[0].conclusion.value.value == "success"
344+
assert checks[0].conflicts.value == []

changelog/7278.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in schema integrity checks of a proposed change that prevented resolved violations from being removed

0 commit comments

Comments
 (0)