question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PIP-210: Admin API should be able to return messages in human-readable formats.

See original GitHub issue

Motivation

Currently, pulsar-admin topics peek-messages and the REST equivalent return the message payload in their original binary form. In the case that the topic has a complex schema, for example, AVRO, protobuf-encoded binary is returned. This results in two issues.

  1. The output can be unreadable with hidden charractors.
  2. The response from the REST API doesn’t conform to HTTP standard. Binary data are not properly encoded or have the right headers set.

Goal

Ability to ask Pulsar broker’s Admin API to return properly encoded string payload, instead of binary payload.

API Changes

  1. API /admin/v2/:schema/:tenant/:namespace/:topic/subscription/:subName/position/:messagePosition will have an optional query parameter asString. Valid values are true or false. When set to be true, the returned payload will be encoded according to the topic’s schema.
  2. pulsar-admin topics peek-messages will add an optional flag --string. If set to true, output would have the payload encoded as string per the topic’s schema.

Implementation

When handling peek request, broker admin currently first retrieves the entry from managed ledger. Then read the binary form from the entry before packaging it as part of REST response.

Before the binary is returned, the broker would make a request to schemaRegistryService asking for the schema from the schema storage. Once found, the broker would read the schema and encode the payload accordingly.

Alternatives

No response

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
teabotcommented, Oct 6, 2022

When we speak about “string” format, we are being too general. You can have a many different string formats after all: Base64, Yaml, JSON, etc. So I think it is a mistake to refer to this as string. Instead I’d recommend explicitly naming the format, and also including an extensible option mechanism like:

--format=binary     # default for backwards compatibility
--format=json
0reactions
codelipenghuicommented, Oct 24, 2022

And in this case is the user constrained to use the java client? How about the use case where the caller is a UI browser?

I think https://www.npmjs.com/package/avro-js and https://github.com/protobufjs/protobuf.js/ can help with the avro and protobuf format.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PIP-210: Admin API should be able to return ... - GitHub
Apache Pulsar - distributed pub-sub messaging system - PIP-210: Admin API should be able to return messages in human-readable formats.
Read more >
Articles Guide to using Duo's Admin API to pull logs
KB Guide: A Duo Security Knowledge Base guide to using Duo's Admin API to pull logs. ... The ability to send in different...
Read more >
REST Resource: users | Google Workspace Directory API
The Directory API allows you to create and manage your account's users, ... As a reseller administrator, you can use the resold customer...
Read more >
Admin API - v3.1.x - Kong Docs
Requests to the Admin API can be sent to any node in the cluster, ... To learn more about the file format, see...
Read more >
API Response Codes - Trend Micro
Some resources support the GET method only. If any other method is requested, this error code will be returned. 400. InvalidFormat. Invalid request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found