diff --git a/.changeset/eight-carpets-yell.md b/.changeset/eight-carpets-yell.md new file mode 100644 index 0000000000..59934035c9 --- /dev/null +++ b/.changeset/eight-carpets-yell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-app-backend': patch +--- + +Return HTTP status 400 rather than 500 when receiving an unknown POST request. diff --git a/plugins/app-backend/src/service/router.ts b/plugins/app-backend/src/service/router.ts index cd1c0e4ee2..9e1c61b9fc 100644 --- a/plugins/app-backend/src/service/router.ts +++ b/plugins/app-backend/src/service/router.ts @@ -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 /'); } }, );