adding error message when created message has wrong header format (#2033)

This commit is contained in:
Robert Azizbekyan 2022-05-30 18:36:04 +04:00 committed by GitHub
parent 7211a18b57
commit 7ba10c1b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,8 +102,14 @@ const SendMessage: React.FC = () => {
}) => {
if (messageSchema) {
const { partition, key, content } = data;
const headers = data.headers ? JSON.parse(data.headers) : undefined;
const errors = validateMessage(key, content, messageSchema);
if (data.headers) {
try {
JSON.parse(data.headers);
} catch (error) {
errors.push('Wrong header format');
}
}
if (errors.length > 0) {
const errorsHtml = errors.map((e) => `<li>${e}</li>`).join('');
dispatch(
@ -117,7 +123,7 @@ const SendMessage: React.FC = () => {
);
return;
}
const headers = data.headers ? JSON.parse(data.headers) : undefined;
try {
await messagesApiClient.sendTopicMessages({
clusterName,