Skip to content

Conversation

@TheFellow
Copy link
Collaborator

@TheFellow TheFellow commented Jan 6, 2026

Issue #125 & #44

I was attempting to use cedar.EntityUIDs directly as keys in a bstore (bbolt) K/V store but needed to do some juggling to make it work.

This PR implements a straightforward variant of EntityUID.UnmarshalCedar and uses that to implement the encoding.BinaryMarshaler and encoding.BinaryUnmarshaler interfaces.

@TheFellow TheFellow force-pushed the support-binary-marshaler branch from 6b5228b to 6772b71 Compare January 6, 2026 00:40
@TheFellow TheFellow force-pushed the support-binary-marshaler branch from 1c60eb1 to 4ddef61 Compare January 6, 2026 01:47
Signed-off-by: Ryan Harris <[email protected]>
Copy link
Collaborator

@philhassey philhassey left a comment

Choose a reason for hiding this comment

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

LGTM @patjakdev can you give it a quick second look?

Copy link
Collaborator

@patjakdev patjakdev left a comment

Choose a reason for hiding this comment

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

Thank you!


// UnmarshalCedar parses a Cedar language representation of an EntityUID.
func (e *EntityUID) UnmarshalCedar(data []byte) error {
// NB: In a perfect world we'd use the full parsing from internal/parser, but
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for writing this up. It's good to document our warts.

s := string(data)
idx := strings.Index(s, "::\"")
if idx <= 0 {
// If idx == 0, the entity has no type, which is invalid.
Copy link
Collaborator

Choose a reason for hiding this comment

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

tiny nit, == should be <=

Alternatively, just remove the comment :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I actually was only referring to the == 0 case for this comment. If we do find the ::" string but it's the first thing then there is no entity type which is also invalid. (There a test that exercises this scenario)

Signed-off-by: Ryan Harris <[email protected]>
@TheFellow TheFellow merged commit 77d5543 into main Jan 6, 2026
6 checks passed
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.

4 participants