Skip to content

REST will return Json instead of ProtoJson #164

Merged
raphael-goetz merged 3 commits intomainfrom
161-false-return-format
Mar 1, 2026
Merged

REST will return Json instead of ProtoJson #164
raphael-goetz merged 3 commits intomainfrom
161-false-return-format

Conversation

@raphael-goetz
Copy link
Member

Resolves: #161

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the REST adapter response serialization so that protobuf Value payloads are converted into standard JSON output (instead of protobuf’s kind-shaped “proto-json”), addressing issue #161.

Changes:

  • Added a pb_value_to_json converter from tucana::shared::Value to serde_json::Value.
  • Updated the response payload serialization path to serialize the converted JSON value.
Comments suppressed due to low confidence (1)

adapter/rest/src/main.rs:251

  • The successful response path serializes payload to JSON bytes but does not ensure a Content-Type: application/json header is present (unlike json_error). If flows omit this header, clients may not treat the body as JSON; consider adding a default content-type when building the response (without overriding an explicit flow-provided value).
            // payload -> json bytes
            let json_val = pb_value_to_json(payload_val);
            let json = serde_json::to_vec_pretty(&json_val).unwrap_or_else(|err| {
                format!(r#"{{"error":"Serialization failed: {:?}"}}"#, err).into_bytes()
            });

            let status =
                StatusCode::from_u16(code as u16).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR);
            build_response(status, http_headers, json)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

raphael-goetz and others added 2 commits March 1, 2026 09:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
@raphael-goetz raphael-goetz merged commit add2ee3 into main Mar 1, 2026
4 checks passed
@raphael-goetz raphael-goetz deleted the 161-false-return-format branch March 1, 2026 11:58
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.

REST Adapter Returns ProtoJson not Json

2 participants