Skip to content

Commit

Permalink
ARC-1733 - Correcting SLO for github/configuration (#1657)
Browse files Browse the repository at this point in the history
* - Added an id for frontend-log-middleware.ts
- Updated the 500 error to 404 for MISSING_JIRA_HOST

* - Log added

* - Review changes

* - Status code updated
  • Loading branch information
krazziekay committed Oct 11, 2022
1 parent 0e3dd03 commit 215d80b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/middleware/frontend-log-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { booleanFlag, BooleanFlags, stringFlag, StringFlags } from "config/featu
import { defaultLogLevel, getLogger } from "config/logger";
import { getUnvalidatedJiraHost } from "middleware/jirahost-middleware";
import { merge } from "lodash";
import { v4 as newUUID } from "uuid";

/*
Expand Down Expand Up @@ -55,6 +56,8 @@ export const LogMiddleware = async (req: Request, res: Response, next: NextFunct
}
};

req.addLogFields({ id: newUUID() });

res.once("finish", async () => {
if ((res.statusCode < 200 || res.statusCode >= 500) && !(res.statusCode === 503 && await booleanFlag(BooleanFlags.MAINTENANCE_MODE, false))) {
req.log.warn({ res, req }, `Returning HTTP response of '${res.statusCode}' for path '${req.path}'`);
Expand Down
4 changes: 3 additions & 1 deletion src/routes/github/configuration/github-configuration-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export const GithubConfigurationGet = async (req: Request, res: Response, next:
req.log.debug("found github token");

if (!jiraHost) {
return next(new Error(Errors.MISSING_JIRA_HOST));
req.log.warn({ req, res }, Errors.MISSING_JIRA_HOST);
res.status(400).send(Errors.MISSING_JIRA_HOST);
return next();
}

req.log.debug(`found jira host: ${jiraHost}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export const GithubCreateBranchOptionsGet = async (req: Request, res: Response,
const { issue_key: key } = req.query;

if (!jiraHost) {
return next(new Error(Errors.MISSING_JIRA_HOST));
req.log.warn({ req, res }, Errors.MISSING_JIRA_HOST);
res.status(400).send(Errors.MISSING_JIRA_HOST);
return next();
}

if (!key) {
Expand Down

0 comments on commit 215d80b

Please sign in to comment.