Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. π₯
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
Treat a lock answer without a usable `allowed` as unavailable, not denied
Rakshith Ramprakashf69281b9591f
diff --git a/apps/api/src/services/autumn/__tests__/autumn.service.test.ts b/apps/api/src/services/autumn/__tests__/autumn.service.test.tsindex c70ce2811..ea5b15aa1 100644--- a/apps/api/src/services/autumn/__tests__/autumn.service.test.ts+++ b/apps/api/src/services/autumn/__tests__/autumn.service.test.ts@@ -971,6 +971,23 @@ describe("firebill routing", () => {expect(mockCheck).not.toHaveBeenCalled();});+ it("maps success without a usable allowed to skipped, not denied", async () => {+ state.configRef = firebillConfig();+ // Not a shape firebill sends today; a denial here would hard-stop the+ // monitor check (skipped_no_credits) on what is really a non-answer.+ mockFetch.mockResolvedValue(lockResponse({ success: true }));+ const svc = makeService();++ const result = await svc.lockCredits({+ teamId: "team-1",+ value: 10,+ lockId: "lock-1",+ });++ expect(result).toEqual({ status: "skipped" });+ expect(mockCheck).not.toHaveBeenCalled();+ });+it("maps firebill lock unavailability to skipped β proceed unlocked, no Autumn fallback", async () => {state.configRef = firebillConfig();const svc = makeService();diff --git a/apps/api/src/services/autumn/firebill.ts b/apps/api/src/services/autumn/firebill.tsindex 7d14b1de3..79ef008da 100644--- a/apps/api/src/services/autumn/firebill.ts+++ b/apps/api/src/services/autumn/firebill.ts@@ -229,7 +229,7 @@ export async function firebillLock({return { status: "unavailable" };}- if (body.allowed !== true) {+ if (body.allowed === false) {logger.info("firebill lock denied", {customerId,entityId,@@ -240,6 +240,21 @@ export async function firebillLock({return { status: "denied" };}+ // Only an explicit `allowed: false` is a denial. `success: true` with a+ // missing or mis-shaped `allowed` is not an answer firebill sends today;+ // treating it as a denial would hard-stop the check (skipped_no_credits),+ // so it maps to unavailable β proceed unlocked β instead.+ if (body.allowed !== true) {+ logger.error("firebill lock answered without a usable `allowed`", {+ customerId,+ entityId,+ featureId,+ value,+ lockId,+ });+ return { status: "unavailable" };+ }+logger.info("firebill lock succeeded", {customerId,entityId,