skycfg icon indicating copy to clipboard operation
skycfg copied to clipboard

Make protobuf map --> starlark.Dict ordering deterministic

Open ryanpbrewster opened this issue 5 months ago • 0 comments

If I have a protobuf map in the host environment (say as a context variable), iterating through it is non-deterministic. That results in some pretty gnarly workarounds in the starlark code itself.

This PR performs some best-effort deterministic at the starlark conversion stage. It ensures that protobuf map items are inserts into the starlark dictionary in naturally sorted order (using starlark's own internal partial ordering).

Sorting is really awkward in starlark itself, so this type of convenience is extremely helpful

ryanpbrewster avatar Sep 23 '24 14:09 ryanpbrewster