fix(audit-log): prevent invalid SQL when projectId is undefined#5264
Open
adionit7 wants to merge 1 commit intoInfisical:mainfrom
Open
fix(audit-log): prevent invalid SQL when projectId is undefined#5264adionit7 wants to merge 1 commit intoInfisical:mainfrom
adionit7 wants to merge 1 commit intoInfisical:mainfrom
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Greptile OverviewGreptile SummaryAdded defensive validation in the audit log queue worker to prevent invalid SQL queries when both Key Changes:
Notes:
Confidence Score: 4/5
Important Files Changed
|
Fixes Infisical#5160 When orgId is not provided, the audit log queue service attempts to fetch the project using projectDAL.findById() even when projectId is null or undefined, causing an invalid SQL query error. This fix adds validation to ensure projectId exists before attempting to fetch the project, and throws a BadRequestError with proper logging if both orgId and projectId are undefined. Changes: - Add validation check for projectId before database query - Add error logging for debugging edge cases - Use BadRequestError consistent with codebase patterns
85c6871 to
94442ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Fixes #5160
Problem:
When
orgIdis not provided, the audit log queue service attempts to fetch the project usingprojectDAL.findById()even whenprojectIdisnullorundefined, causing an invalid SQL query error.Before:
projectDAL.findById(projectId as string)without checking ifprojectIdexistsprojectIdwasnullorundefinedAfter:
projectIdexists before attempting to fetch the projectBadRequestErrorwith proper logging if bothorgIdandprojectIdare undefinedScreenshots
N/A - Backend fix only, no UI changes
Steps to verify the change
docker compose -f docker-compose.dev.yml up --build --force-recreateorgIdis missing andprojectIdisnull/undefinedBadRequestErroris thrown with a clear error messageType
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).