Skip to content

Commit

Permalink
Merge pull request #4966 from mozilla/MNTOR-3465
Browse files Browse the repository at this point in the history
MNTOR-3465: HIBP responses with 429
  • Loading branch information
mansaj authored Aug 24, 2024
2 parents f0f7e8f + 5bd6ee3 commit 1439d90
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/api/v1/hibp/notify/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { NextRequest, NextResponse } from "next/server";
import { captureMessage } from "@sentry/node";

import { bearerToken } from "../../../utils/auth";
import { logger } from "../../../../functions/server/logging";
Expand Down Expand Up @@ -55,6 +56,7 @@ export async function POST(req: NextRequest) {
pubsub = new PubSub({ projectId });
} catch (ex) {
logger.error("error_connecting_to_pubsub:", { exception: ex as string });
captureMessage(`error_connecting_to_pubsub: ${ex as string}`);
return NextResponse.json({ success: false }, { status: 429 });
}

Expand All @@ -72,9 +74,10 @@ export async function POST(req: NextRequest) {
await pubsub.topic(topicName).createSubscription(subscriptionName);
} else {
logger.error("pubsub_topic_not_found:", { topicName });
return NextResponse.json({ success: false }, { status: 500 });
captureMessage(`pubsub_topic_not_found: ${topicName}`);
return NextResponse.json({ success: false }, { status: 429 });
}
logger.error("error_queuing_hibp_breach:", { topicName });
return NextResponse.json({ success: false }, { status: 500 });
return NextResponse.json({ success: false }, { status: 429 });
}
}

0 comments on commit 1439d90

Please sign in to comment.