Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
N/A
Does the issue happen when logged out?
N/A (backend source bug)
Does the issue happen in incognito mode when logged in?
N/A
Does the issue happen in incognito mode when logged out?
N/A
Issue details
Current Behavior
In backend/src/dal/new-quotes.ts, git is initialized via tryCatchSync at module load:
// new-quotes.ts:33-35
const { data: git, error } = tryCatchSync(() =>
simpleGit(path.join(__dirname, PATH_TO_REPO)),
);
On failure this yields data === undefined (which add() checks correctly):
// new-quotes.ts:59
if (git === undefined) throw new MonkeyError(500, "Git not available.");
But approve() checks against null instead, making the guard dead code:
// new-quotes.ts:150
if (git === null) throw new MonkeyError(500, "Git not available.");
If git initialization failed at import time, the check passes, execution reaches line 181 (await git.pull("upstream", "master")) and crashes with a raw TypeError: Cannot read properties of undefined instead of the intended structured 500 MonkeyError.
Expected Behavior
Line 150 should mirror line 59:
if (git === undefined) throw new MonkeyError(500, "Git not available.");
Steps To Reproduce
- Deploy the backend where
simpleGit(...) init throws (e.g. repo path unavailable).
- Approve a quote as a quote moderator.
- Endpoint responds with an unhandled TypeError rather than the expected
500 "Git not available." error shape.
Environment
Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
N/A
Does the issue happen when logged out?
N/A (backend source bug)
Does the issue happen in incognito mode when logged in?
N/A
Does the issue happen in incognito mode when logged out?
N/A
Issue details
Current Behavior
In
backend/src/dal/new-quotes.ts,gitis initialized viatryCatchSyncat module load:On failure this yields
data === undefined(whichadd()checks correctly):But
approve()checks againstnullinstead, making the guard dead code:If git initialization failed at import time, the check passes, execution reaches line 181 (
await git.pull("upstream", "master")) and crashes with a rawTypeError: Cannot read properties of undefinedinstead of the intended structured 500MonkeyError.Expected Behavior
Line 150 should mirror line 59:
Steps To Reproduce
simpleGit(...)init throws (e.g. repo path unavailable).500 "Git not available."error shape.Environment
master@ 91bd24b