Merge branch 'dev' into promptless/changelog-oauth-retry-reliability

This commit is contained in:
promptless[bot] 2026-04-14 03:50:03 +00:00
commit 8e02141bcd
2 changed files with 2 additions and 32 deletions

View File

@ -1,4 +1,5 @@
import { sendSupportFeedbackEmail } from "@/lib/internal-feedback-emails";
import { isLocalEmulatorEnabled } from "@/lib/local-emulator";
import { createSmartRouteHandler } from "@/route-handlers/smart-route-handler";
import { DEFAULT_BRANCH_ID, getSoleTenancyFromProjectBranch } from "@/lib/tenancies";
import { adaptSchema, emailSchema, yupBoolean, yupNumber, yupObject, yupString } from "@stackframe/stack-shared/dist/schema-fields";
@ -45,7 +46,7 @@ export const POST = createSmartRouteHandler({
async handler({ auth, body }) {
// Forward to production in local emulator (same pattern as AI query endpoint)
const feedbackMode = getEnvVariable("STACK_FEEDBACK_MODE", "email");
if (feedbackMode === "FORWARD_TO_PRODUCTION") {
if (feedbackMode === "FORWARD_TO_PRODUCTION" && isLocalEmulatorEnabled()) {
const prodResponse = await fetch("https://api.stack-auth.com/api/latest/internal/feedback", {
method: "POST",
headers: { "content-type": "application/json", "accept-encoding": "identity" },

View File

@ -2,31 +2,8 @@ import { describe } from "vitest";
import { it } from "../../../../../helpers";
import { Auth, backendContext, createMailbox, niceBackendFetch, waitForOutboxEmailWithStatus } from "../../../../backend-helpers";
/**
* Probe the backend to detect whether it's forwarding feedback to production.
* Cached so we only make one probe request per test run.
*/
let cachedIsForwarding: boolean | null = null;
async function isForwardingToProduction(): Promise<boolean> {
if (cachedIsForwarding !== null) return cachedIsForwarding;
const probe = await niceBackendFetch("/api/v1/internal/feedback", {
method: "POST",
body: {
email: "probe@test.stack-auth.com",
message: "mode detection probe",
},
});
// When forwarding, production rejects and we get a non-200 with "forward" in the body
cachedIsForwarding = probe.status !== 200;
return cachedIsForwarding;
}
describe("POST /api/v1/internal/feedback", () => {
it("should send feedback from an authenticated user", async ({ expect }) => {
if (await isForwardingToProduction()) {
return; // forwarding mode — probe already verified endpoint is reachable
}
const senderEmail = backendContext.value.mailbox.emailAddress;
const signInResult = await Auth.Otp.signIn();
const recipientMailbox = createMailbox("team@stack-auth.com");
@ -67,10 +44,6 @@ describe("POST /api/v1/internal/feedback", () => {
});
it("should send feedback without authentication (dev tool)", async ({ expect }) => {
if (await isForwardingToProduction()) {
return;
}
const recipientMailbox = createMailbox("team@stack-auth.com");
const subject = "[Support] devtool-user@example.com";
@ -107,10 +80,6 @@ describe("POST /api/v1/internal/feedback", () => {
});
it("should send bug reports with correct label", async ({ expect }) => {
if (await isForwardingToProduction()) {
return;
}
const recipientMailbox = createMailbox("team@stack-auth.com");
const subject = "[Bug Report] bug@example.com";