fix: File metadata endpoint returns HTTP 200 instead of 403 for invalid app ID#10527
fix: File metadata endpoint returns HTTP 200 instead of 403 for invalid app ID#10527dblythy wants to merge 1 commit into
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
📝 WalkthroughWalkthroughThe ChangesMetadata Handler Error Response Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.44.0)spec/ParseFile.spec.jsast-grep timed out on this file Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Routers/FilesRouter.js (1)
840-845: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate invalid-app-ID response pattern across handlers.
This exact three-line block (
createSanitizedHttpError+res.status+res.json) now appears ingetHandler(Line 214-217),_earlyHeadersMiddleware(Line 324-327), andmetadataHandler(Line 841-844). Consider extracting a small private helper (e.g.,_sendSanitizedError(res, status, message, config)) to reduce duplication.♻️ Example helper extraction
+ static _sendSanitizedError(res, status, message, config) { + const error = createSanitizedHttpError(status, message, config); + res.status(error.status); + res.json({ error: error.message }); + } + async metadataHandler(req, res) { try { const config = Config.get(req.params.appId); if (!config) { - const error = createSanitizedHttpError(403, 'Invalid application ID.', config); - res.status(error.status); - res.json({ error: error.message }); + FilesRouter._sendSanitizedError(res, 403, 'Invalid application ID.', config); return; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Routers/FilesRouter.js` around lines 840 - 845, The invalid application ID response logic is duplicated across getHandler, _earlyHeadersMiddleware, and metadataHandler, so extract the shared createSanitizedHttpError + res.status + res.json sequence into a small private helper such as _sendSanitizedError in FilesRouter and replace each repeated block with that helper call. Keep the helper near the other router methods so the handlers remain readable and continue passing the same config, status, and message values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/Routers/FilesRouter.js`:
- Around line 840-845: The invalid application ID response logic is duplicated
across getHandler, _earlyHeadersMiddleware, and metadataHandler, so extract the
shared createSanitizedHttpError + res.status + res.json sequence into a small
private helper such as _sendSanitizedError in FilesRouter and replace each
repeated block with that helper call. Keep the helper near the other router
methods so the handlers remain readable and continue passing the same config,
status, and message values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 805d9f01-abee-4ba6-bff0-77d500acace0
📒 Files selected for processing (2)
spec/ParseFile.spec.jssrc/Routers/FilesRouter.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10527 +/- ##
==========================================
+ Coverage 92.66% 92.68% +0.01%
==========================================
Files 193 193
Lines 16981 16982 +1
Branches 248 248
==========================================
+ Hits 15736 15739 +3
+ Misses 1224 1222 -2
Partials 21 21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #10108
Summary by CodeRabbit
403 Permission denied) instead of appearing successful.