Publish events for agent personas and ACLs - #1372
Open
tomchop wants to merge 2 commits into
Open
Conversation
Both failed to become events, silently. Publishing is wrapped in a try/except that logs, so the write still landed and only the log said anything. AgentPersona failed twice over: it never exposed `root_type`, which the discriminator reads off the instance, and it had no member in YetiObjectTypes. RoleRelationship exposed `root_type` but had no union member either. Neither is in the skip-guard that save() and delete() apply to auditlog and timeline, so both were meant to publish all along. Guarded by two tests over the schema registry rather than a case per type: one that every publishable object exposes `root_type`, one that every publishable root_type has a union member. Reverting either half of the fix fails them, and the second names both gaps on its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1371.
AgentPersonaandRoleRelationshipboth threwunion_tag_not_foundwhile publishing their events, on every save and delete. The exception is caught and logged, so the write still landed — the only symptoms were log noise and events that never fired.Two distinct causes
Investigating turned up more than the issue described:
AgentPersonanever exposedroot_type. Every other Yeti object has it as acomputed_field; this one had only the private_root_type. The discriminator doesgetattr(v, "root_type", None), so it resolved toNone— adding a union member alone would not have fixed it.agent_personanoraclhad a union member inYetiObjectTypes.Why
aclis included and the others aren'tThe issue asked which of the five missing
_root_types were deliberate.save()anddelete()already answer it: both skipauditlogandtimelineby collection name, so their absence from the union is correct and intentional — they never publish.packageis a plainBaseModel, not Arango-backed, so it cannot publish either.aclsis in neither the skip-guard nor the union, so the code's expressed intent is that it publishes. It just threw instead. That is the evidence for fixing it rather than guarding it, but say the word if RBAC changes are meant to stay silent and I will guard the collection instead.Tests
Two guards over the schema registry rather than a case per type, so a new schema cannot reintroduce either half:
root_typeroot_typehas a union memberReverting the fix fails both, and the second names
{'agent_persona', 'acl'}on its own. Plus end-to-end coverage that saving and deleting a persona each put an event on the queue.Note
root_typeis acomputed_field, so it now appears in persona API responses, as it does for every other object. Additive, and requests are unaffected since computed fields are output-only — but the frontend'sapi-schema.d.tswill pick it up on its next regeneration.