-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Open
Description
Summary
The metadataHandler in src/Routers/FilesRouter.js returns HTTP 200 with an empty JSON object ({}) when the app ID is invalid (config is missing), while getHandler returns HTTP 403 with "Invalid application ID." for the same condition. This inconsistency can mask configuration errors for callers of the metadata endpoint.
Expected behavior
metadataHandler should return HTTP 403 with an appropriate error message when the config is missing, consistent with getHandler:
const config = Config.get(req.params.appId);
if (!config) {
- res.status(200);
- res.json({});
+ const error = createSanitizedHttpError(403, 'Invalid application ID.', config);
+ res.status(error.status);
+ res.json({ error: error.message });
return;
}The existing test does not crash on file metadata request with invalid app ID will need to be updated to assert the new 403 response.
Context
Identified during review of #10106 (comment: #10106 (comment)). The inconsistency predates that PR and is intentionally out of scope for it.
Requested by @mtrezza.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels