bazelbuild / bazelbuild/bazel

Document that JSON format for persistent workers should always return fields

Open
#27,151 1 comment 0 reactions 0 assignees View on GitHub
help wanted P3 team-Documentation team-Remote-Exec type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Page link:

https://bazel.build/remote/creating

### Problem description (include actual vs expected text, if applicable):

According to the [protobuf JSON spec](https://protobuf.dev/programming-guides/json/#presence):

> When generating JSON-encoded output from a protocol buffer, if a field supports presence, serializers must emit the field value if and only if the corresponding hasser would return true.
>
> If the field doesn’t support field presence and has the default value (for example any empty repeated field) serializers should omit it from the output. An implementation may provide options to include fields with default values in the output.

I'm manually creating the response JSON to avoid a protobuf dependency. If I implement according to spec, a `WorkResponse` with exit code of 0, no output, etc. should be an empty JSON object because the fields are all their zero value. But if I do that, the Bazel build hangs. It seems like I need to skip that part of the spec and always serialize zero values. The documentation should clarify any requirements that are non-compliant with spec, so that the next developer doesn't spend 2 hours wondering why my persistent worker code isn't working 😢

### Where do you see this issue? (include link to specific section of the page, if applicable)

_No response_

### Any other information you'd like to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.