Skip to content

Commit eccfa8f

Browse files
MajorTalclaude
andcommitted
Fix init tier display and tier set crash on non-JSON response (v1.13.6)
BUG-002: tier set crashes with SyntaxError when server returns HTML (e.g. ALB 502). Now reads body as text, parses safely, outputs structured JSON error on failure. BUG-003: init always shows Tier: (none) because it checks tierInfo.status === 'active' but the API returns tierInfo.active (boolean). Fixed both the display and next-step checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1d20b1b commit eccfa8f

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

cli/lib/init.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export async function run(args = []) {
173173
}
174174
} catch {}
175175

176-
if (tierInfo && tierInfo.tier && tierInfo.status === "active") {
176+
if (tierInfo && tierInfo.tier && tierInfo.active) {
177177
const expiry = tierInfo.lease_expires_at ? tierInfo.lease_expires_at.split("T")[0] : "unknown";
178178
line("Tier", `${tierInfo.tier} (expires ${expiry})`);
179179
} else {
@@ -185,7 +185,7 @@ export async function run(args = []) {
185185

186186
// 6. Next step
187187
console.log();
188-
if (!tierInfo || !tierInfo.tier || tierInfo.status !== "active") {
188+
if (!tierInfo || !tierInfo.tier || !tierInfo.active) {
189189
console.log(" Next: run402 tier set prototype");
190190
} else {
191191
console.log(" Ready to deploy. Run: run402 deploy --manifest app.json");

cli/lib/tier.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ async function set(tierName) {
3838
if (!tierName) { console.error(JSON.stringify({ status: "error", message: "Usage: run402 tier set <prototype|hobby|team>" })); process.exit(1); }
3939
const fetchPaid = await setupPaidFetch();
4040
const res = await fetchPaid(`${API}/tiers/v1/${tierName}`, { method: "POST", headers: { "Content-Type": "application/json" } });
41-
const data = await res.json();
41+
const text = await res.text();
42+
let data;
43+
try {
44+
data = JSON.parse(text);
45+
} catch {
46+
console.error(JSON.stringify({ status: "error", http: res.status, message: "Non-JSON response from server", body: text.slice(0, 500) }));
47+
process.exit(1);
48+
}
4249
if (!res.ok) { console.error(JSON.stringify({ status: "error", http: res.status, ...data })); process.exit(1); }
4350
console.log(JSON.stringify(data, null, 2));
4451
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "run402-mcp",
3-
"version": "1.13.5",
3+
"version": "1.13.6",
44
"description": "MCP server for Run402 — AI-native Postgres databases with REST API, auth, storage, and row-level security. Pay with x402 USDC micropayments.",
55
"type": "module",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)