Linking billing account fails from the prototype stage - why this bug still exists?

This type of nasty bugs put projects into stagnation for literally no reason. I’ve reported it but nothing has changed.

1 Like

Candidate Public Response (Forum)

Regarding the “Link billing account fails in prototype stage” issue

Hi ranroby1 —this happened as a likely result of having developed your application in a way that will take you outside of what the application can do.

Going forward I recommend you have a solid GitHub Repo with recent Commits and PR. That you test locally first prior to allowing others to enter sensitive information; to validate your Security Layers and Permissions. Take 72-hrs to read the documentation and another 48 hrs to look over your application for vulnerabilities; this can trigger Defaults unintentionally that are built into a lot of applications; it will try to stick to what it knows to be procedurally correct in an effort to help you stay compliant.

Based on what’s happening here, I recommend the following diagnostic path and workaround:


:hammer_and_wrench: What to Check & Try

  1. Verify permissions
    Make sure that the Google account (or service account) you’re using has billing-admin or equivalent permissions (e.g. billing.accounts.link, resourcemanager.projects.update) on that project and on the billing account you’re linking. If you lack the right IAM role, linking will fail silently or error out generically.

  2. Ensure billing APIs are enabled
    In the Cloud Console, check that the Cloud Billing API and Billing Account Services APIs are enabled for your GCP organization / project. If these APIs aren’t active, the linking call will be rejected upstream.

  3. Remove or override fallback billing state
    If the prototype / agent layer has already assumed or injected a default billing account, that may conflict with your attempt to link your real account.
    Try creating a fresh project (without any default billing assumptions), then link your desired billing account before the prototype steps run. This avoids fallback collisions.

  4. Inspect detailed error logs / console output
    Use the GCP Console → Activity / Logs, or audit logs for billing linking calls. Look for error codes like PERMISSION_DENIED, BILLING_NOT_ENABLED, INVALID_ARGUMENT, etc. That gives insight into which checkpoint is failing.

  5. Retry linking at a safe point
    Rather than linking during the prototype bootstrap process, try doing it after the project is fully created but before you run higher-tier provisioning. Sometimes sequencing matters: linking too early might conflict with agent initialization

this next part I developed from my own project:

:light_bulb: Billing Link Inspector

:one: Create the script

Save this as billing-link-inspector.js in any Node environment that has the Google Cloud CLI and credentials set up.

#!/usr/bin/env node
/**
 * Billing Link Inspector
 * ----------------------
 * A read-only diagnostic utility that checks:
 *   1. Whether Cloud Billing API is enabled
 *   2. Whether the current identity has permission to link billing
 *   3. Whether the project already has a billing account attached
 */

import { google } from "googleapis";

const projectId = process.argv[2];
if (!projectId) {
  console.error("Usage: node billing-link-inspector.js <PROJECT_ID>");
  process.exit(1);
}

async function main() {
  const auth = await google.auth.getClient({
    scopes: ["https://www.googleapis.com/auth/cloud-billing.readonly",
             "https://www.googleapis.com/auth/cloud-platform"]
  });
  const billing = google.cloudbilling({ version: "v1", auth });
  const serviceusage = google.serviceusage({ version: "v1", auth });

  try {
    // 1️⃣ Check whether Cloud Billing API is enabled
    const api = await serviceusage.services.get({
      name: `projects/${projectId}/services/cloudbilling.googleapis.com`,
    });
    const apiEnabled = api.data.state === "ENABLED";
    console.log(`🔍 Cloud Billing API enabled: ${apiEnabled}`);

    // 2️⃣ Fetch project billing info
    const res = await billing.projects.getBillingInfo({ name: `projects/${projectId}` });
    const info = res.data;
    if (info.billingAccountName) {
      console.log(`✅ Linked billing account: ${info.billingAccountName}`);
    } else {
      console.log("⚠️ No billing account linked to this project.");
    }

    // 3️⃣ Check effective permissions (if possible)
    const test = await billing.billingAccounts.testIamPermissions({
      resource: "billingAccounts/",
      requestBody: { permissions: ["billing.accounts.link"] },
    });
    console.log(`👤 Current identity can link billing: ${test.data.permissions?.length > 0}`);

  } catch (err) {
    console.error("❌ Error while inspecting billing state:", err.message);
  }
}

main();

Make it executable:

chmod +x billing-link-inspector.js

Run:

node billing-link-inspector.js <YOUR_PROJECT_ID>


:two: What the output tells you

Indicator Meaning Typical Action
Cloud Billing API enabled: false The API itself isn’t active Enable it in GCP Console → APIs → Enable Billing API
No billing account linked Project has no account Link manually in Cloud Console or via CLI
Current identity can link billing: false Missing IAM permission Add “Billing Account User” role for this identity

Let me know if this helps to move your project forward.

hi, and thanks for your detailed comment. I’ve tried all the suggested step and still could not manage the billing system. The proccess must work in the most simple way straight from the prototyer stage without all thise complexities. This should be 3 clicks process and should not take hours of searches and modifications. FB studio appeals people without any technical background. This complexity will make them quit quite quickley. Regards.

Tell me what’s blocking you. I’ll see if I can simplify the steps. Another alternative is to add me in your Auth so I can see the problem first hand. It actually is a few clicks to get in trouble with billing and a whole process to fix.
I personally love challenges and I encourage you to embrace them if you’re going to be a developer. I understand more than you know. I can’t show my bank statement but my company will have to close its account.
I will not be able to monetize or develop anything with no account. However I did figure out how to use this application. Fair trade? No. Can I fix your problem? Yes. It’s a process though and either you can do it or you can let it drag on, till you have to quit or hire a pro
Let me know what you’re seeing I’ll help you help yourself

Thanks for the willing to help. at the meanwhile i have even bigger problems in my project as it refuses to initilize no matter what i do and show 404 error out of blue since yesterday. the project is totally disabled without any ability to continue and i could not manage to fix it. i dunno why it happened and what could cause this but it feels like microsoft’s BSOD by any mean.

Great job my friend! Hang in there. Yes it can definitely be Microsoft tripping you up or contributing. First, let me try to surface the errors for you that could be behind the errors you see.

To do so I need to know if you used Code Snippets in your design to start or if you at any point introduced or used them and for which file.

Next are you using images in your project? If so what type are they, jpeg png files? You will need to convert them to modern day browsing file types. Your images and styling should be in css, this should help with rendering which can be a problem

I’m a little behind my own schedule, when I’m able I’ll send you a Sanity Checklist to help see everything that’s broken or breaking the project

I doubt it’s images problem sine I did not use any invalid images. They all work in my other projects. Other than that, I did not use any pasted codes. Only those that created by the prototyper itself. All my other projects seems to work normally. Only the current one has this problem. I tried switching to other database account, tried HAR file analizing, tried any solution from CHATgpt. Nothing worked. Thanks.

1 Like

No worries @ranroby1 I have not forgotten you. I am working on a way to get you back in the driver seat.

It doesn’t seem like much from the image (NodeJS image), it’s just to say how does your Development Environment Look? Not just you, most anyone looking to be a better developer. Your Dev Ops Folder should be able to deploy testing windows (NodeJS image) that allow you to work with your code in Real Time.

Take screenshots of your Terminal for me so I can see what errors exist in the project. Excuse me the proper way to ask is can you see your project in the mode shown in the image, if so, screen capture the Terminal. Provide any images you think will be helpful, if you are not able to see this window. Could you open your Window for your browser and look for errors there for me as well?

It will take me a sec to get back to you, as you can see, I’m supposed to be working. :upside_down_face:

I just thought of another short cut: List all the errors you can for me that you know exist in your project if you can see the workspace like the image below

Thanks again! the feedbacks i get from FB studio are quite basic, as you can see in the attached image. Nothing harsh. very standard 404 error that definitelly is not telling whole story.



1 Like

I can see the issue clearly now.

Based on the screenshots you just sent, plus the thread summary:

:white_check_mark: Your Firebase Studio instance is running a Next.js 14.2.32 app successfully — it compiles and starts but returns a 404 because it’s hitting the base route (/) with no page defined.
:white_check_mark: The cross-origin warning (allowedDevOrigins) is just a notice from the newer Next.js dev server — not a fatal error.
:white_check_mark: The real problem is that there’s no page.tsx or index.tsx (under src/app/ or src/pages/) to render your entry route, so you get “This page could not be found.”

:puzzle_piece: To confirm next step:
Can you show me the folder structure under your src/ directory?
If there’s no src/app/page.tsx or src/pages/index.tsx, I’ll issue you a short “Landing Diagnostic Patch” you can drop in to verify routing and rule out Firebase host linkage as the cause.

Once that’s confirmed, we can move on to the billing linkage issue in Firebase Studio (which is likely unrelated to this 404).

:test_tube: Landing Diagnostic Patch

Place this minimal route component so that the root URL (“/”) always renders something obvious. Use either the app router or pages router depending on your setup. Try both if you’re unsure.

If you use App Router (src/app/)

Create (or overwrite) src/app/page.tsx:

// src/app/page.tsx
export default function Landing() {
  return (
    <main style={{
      display: 'flex', justifyContent: 'center', alignItems: 'center',
      height: '100vh', fontSize: '2rem'
    }}>
      ✅ Landing Diagnostic Patch — Page Loaded
    </main>
  );
}

If you use Pages Router (src/pages/)

Create (or overwrite) src/pages/index.tsx:

// src/pages/index.tsx
export default function Home() {
  return (
    <div style={{
      display: 'flex', justifyContent: 'center', alignItems: 'center',
      height: '100vh', fontSize: '2rem'
    }}>
      ✅ Landing Diagnostic Patch — Page Loaded
    </div>
  );
}


:open_file_folder: PowerShell Script to List Folder Structure

Save this as list-structure.ps1 at your project root (or just run inline in PowerShell):

# list-structure.ps1
Get-ChildItem -Recurse -Force | `
  Select-Object FullName, Mode | `
  Where-Object { $_.PSIsContainer -or $_.Mode -match '^-.*' } | `
  Format-Table -AutoSize

Alternatively, run directly in PowerShell:

Get-ChildItem -Recurse -Force | Select FullName | Out-Host

This lists all files and directories recursively, including hidden ones. Use that to verify whether src/app or src/pages contains page.tsx or index.tsx.


:play_button: Command to Start Dev & Open Window

Assuming your package.json has a dev or start script (e.g. "dev": "next dev") — you’d run in PowerShell or terminal:

npm run dev

Then open your browser to the URL printed in console, typically http://localhost:3000 (or the port Next.js says). On Vercel or Firebase preview, it may show a URL like https://your-project.vercel.app or a preview link from Studio.

If you want a one-shot command that opens the browser automatically (Windows example):

Start-Process "http://localhost:3000"

You can append that after starting dev server (in a separate terminal window) or include in a script if you want automation.


:white_check_mark: What to Check & Report Back

  1. After applying the patch and starting dev, does “:white_check_mark: Landing Diagnostic Patch — Page Loaded” show up in browser?

    • If yes → routing is working locally; 404 is likely at deployment or Firebase Studio layer

    • If no → you may have conflicting routing structure, or Next.js may not see your app/pages folder

  2. Use list-structure.ps1 to show me your folder tree (especially look for src/app/page.tsx, src/pages/index.tsx, and any stray “app” folder at root).

  3. Screenshot or copy the terminal output and browser URL/response.

Once I have that, I can guide you further on where the disconnect lies (Firebase Hosting, Studio preview, or manifest routing). Again, this is a process that can seem to drag on. For me I have found that once I know the folder tree and can see specific files or problems it becomes a faster process for me to align the files with Firebase expectations. I will hazard a guess and say that it is manifest routing.

Going forward please create a Development Folder that will have this list-structure.ps1 a file called Sanity Checklist, and your Git Repository, and Dev Logs, Errors thar have been given Ticket Numbers (you can use Slack for this). In one project I was working on this***: if no*** → you may have conflicting routing structure, or Next.js may not see your app/pages folder was the problem I encountered.