nodece opened a new pull request, #21919:
URL: https://github.com/apache/pulsar/pull/21919
### Motivation
When using ` bin/pulsar-admin topics get-message-by-id
public/default/my-topic-1 -e 0 -l 1024` with a non-existent ledger, I expect to
throw the 400 error instead of 500.
CLI log:
```
$ bin/pulsar-admin topics get-message-by-id public/default/my-topic-1 -e 0
-l 1024
--- An unexpected error occurred in the server ---
Message: Message not found, the ledgerId does not belong to this topic or
has been deleted
Stacktrace:
org.apache.bookkeeper.mledger.ManagedLedgerException$LedgerNotExistException:
Message not found, the ledgerId does not belong to this topic or has been
deleted
Reason:
--- An unexpected error occurred in the server ---
Message: Message not found, the ledgerId does not belong to this topic or
has been deleted
Stacktrace:
org.apache.bookkeeper.mledger.ManagedLedgerException$LedgerNotExistException:
Message not found, the ledgerId does not belong to this topic or has been
deleted
```
Broker log:
```
2024-01-18T18:03:46,824+0800 [pulsar-web-47-14] INFO
org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [18/1月/2024:18:03:46 +0800]
"GET /admin/v2/persistent/public/default/my-topic-1/ledger/1024/entry/0
HTTP/1.1" 500 340 "-" "Pulsar-Java-v3.2.0" 29
```
### Modifications
In the `internalGetMessageById`, when `readEntryFailed` returns
LedgerNotExitException, convert this exception to 400 error.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update
later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]