app-backend: 500 -> 400 on unknown POST

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-09-12 22:38:16 +02:00
parent 34a1e72c4f
commit 72a8c7b499
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-backend': patch
---
Return HTTP status 400 rather than 500 when receiving an unknown POST request.
+2 -2
View File
@@ -42,7 +42,7 @@ import {
HttpAuthService,
LoggerService,
} from '@backstage/backend-plugin-api';
import { AuthenticationError } from '@backstage/errors';
import { AuthenticationError, InputError } from '@backstage/errors';
import { injectConfig, readFrontendConfig } from '../lib/config';
// express uses mime v1 while we only have types for mime v2
@@ -220,7 +220,7 @@ export async function createRouter(
req.method = 'GET';
next('router');
} else {
throw new Error('Invalid POST request to /');
throw new InputError('Invalid POST request to /');
}
},
);