From c52beeca50f8b3148b2e2819c6a0a0523c5c9cad Mon Sep 17 00:00:00 2001 From: ManuelLG92 Date: Thu, 30 May 2024 10:13:37 +0200 Subject: [PATCH 1/5] feat: exclude folder <.idea> from git vcs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5071ac1..12927ca 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ trash \.vscode/ \.vs/ +\.idea/ # confluent-schema-registry # From 0aee5f4d2007c3e50a001bbf1d343d72646b7595 Mon Sep 17 00:00:00 2001 From: ManuelLG92 Date: Thu, 30 May 2024 10:14:34 +0200 Subject: [PATCH 2/5] feat: Enhance error middleware --- src/api/middleware/errorMiddleware.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api/middleware/errorMiddleware.ts b/src/api/middleware/errorMiddleware.ts index 4c3ac59..94a7494 100644 --- a/src/api/middleware/errorMiddleware.ts +++ b/src/api/middleware/errorMiddleware.ts @@ -12,9 +12,15 @@ class ResponseError extends Error { url: string constructor(clientName: string, response: ConfluenceResponse) { + const responseData = response.data() + const isResponseDataAnObject = typeof responseData === 'object' + const responseDataString = isResponseDataAnObject ? JSON.stringify(responseData) : responseData + super( - `${clientName} - ${response.data().message || - `Error, status ${response.status()}${response.data() ? `: ${response.data()}` : ''}`}`, + `${clientName} - ${responseData.message || + `Error, status ${response.status()}${ + responseDataString ? `: ${responseDataString}` : '' + }`}`, ) const request = response.request() From ca031aa4b44acf120bf09ebbc52b05abdb1c5599 Mon Sep 17 00:00:00 2001 From: ManuelLG92 Date: Thu, 30 May 2024 10:31:53 +0200 Subject: [PATCH 3/5] feat: add test case --- src/api/middleware/errorMiddleware.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/middleware/errorMiddleware.spec.ts b/src/api/middleware/errorMiddleware.spec.ts index 5d6459a..1296b0b 100644 --- a/src/api/middleware/errorMiddleware.spec.ts +++ b/src/api/middleware/errorMiddleware.spec.ts @@ -56,6 +56,18 @@ describe('ErrorMiddleware', () => { ) }) + it('raises an error with a message in case of client-side object error', async () => { + const message = { cause: 'unknown cause', metadata: { id: 1 } } + const response = createResponse(message) + + await expect( + executedMiddleware.response(() => Promise.reject(response), undefined), + ).rejects.toHaveProperty( + 'message', + `${middlewareParams.clientId} - Error, status 500: ${JSON.stringify(message)}`, + ) + }) + it('raise an error with a default message if the error payload is empty', async () => { const response = createResponse('') From bce1e345eb7cdb8b980c2173cb6283e9d2142774 Mon Sep 17 00:00:00 2001 From: ManuelLG92 Date: Thu, 30 May 2024 10:43:20 +0200 Subject: [PATCH 4/5] feat: add changes to the changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b00c2..997ef69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.3.1] - 2024-05-30 + +### Fixed +- Exclude `.idea` folder from git vcs. +- Show client-side errors when the error data is an object [#261](https://github.com/kafkajs/confluent-schema-registry/pull/261) ## [3.3.0] - 2022-10-04 From ef080c2560269b66d62f3d5eb2a45baada7c0391 Mon Sep 17 00:00:00 2001 From: ManuelLG92 Date: Thu, 30 May 2024 10:43:42 +0200 Subject: [PATCH 5/5] feat: bump library version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a786a1f..aa420a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kafkajs/confluent-schema-registry", - "version": "3.3.0", + "version": "3.3.1", "main": "dist/index.js", "description": "ConfluentSchemaRegistry is a library that makes it easier to interact with the Confluent schema registry, it provides convenient methods to encode, decode and register new schemas using the Apache Avro serialization format.", "keywords": [