Merge pull request #26664 from backstage/rugvip/unknown

app-backend: 500 -> 400 on unknown POST
This commit is contained in:
Patrik Oldsberg
2024-09-13 10:22:22 +03:00
committed by GitHub
2 changed files with 9 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.
+4 -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,9 @@ export async function createRouter(
req.method = 'GET';
next('router');
} else {
throw new Error('Invalid POST request to /');
throw new InputError(
'Invalid POST request to app-backend wildcard endpoint',
);
}
},
);