Skip to content

Firebase Data Connect Admin SDK Code Generation incorrect args for operations with no input #9449

Closed

Description

@jdiekhoff

[REQUIRED] Environment info

firebase-tools: 14.24.2

Platform: macOS Sequoia 15.6.1

[REQUIRED] Test case

GraphQL Schema (Minimal Example)

Create a simple Data Connect query with no input variables:

File: dataconnect/connector/GetItems.gql

query GetItems @auth(level: NO_ACCESS) {
  items {
    id
    name
  }
}

File: dataconnect/connector/connector.yaml

connectorId: "default"
generate:
  adminNodeSdk:
    outputDir: "./generated/admin"
    package: "@firebasegen/connector-admin"

Generated Code (BROKEN)

Run firebase dataconnect:sdk:generate and the generator produces:

function getItems(dcOrOptions, options) {
  const { dc: dcInstance, options: inputOpts} = validateAdminArgs(connectorConfig, dcOrOptions, options, undefined);
  dcInstance.useGen(true);
  return dcInstance.executeQuery('GetItems', inputVars, inputOpts);  // ❌ inputVars is undefined!
};

[REQUIRED] Steps to reproduce

  1. Create a GraphQL query with no input variables:

    mkdir -p dataconnect/connector
    cat > dataconnect/connector/GetItems.gql << EOF
    query GetItems @auth(level: NO_ACCESS) {
      items {
        id
        name
      }
    }
    EOF
  2. Configure connector.yaml with adminNodeSdk:

    connectorId: "default"
    generate:
      adminNodeSdk:
        outputDir: "./generated/admin"
        package: "@firebasegen/connector-admin"
  3. Generate the Admin SDK:

    firebase dataconnect:sdk:generate
  4. Try to use the generated function:

    import { getItems } from './generated/admin';
    import { getDataConnect } from 'firebase-admin/data-connect';
    
    const dataConnect = getDataConnect({ 
      serviceId: 'my-service',
      location: 'us-central1' 
    });
    
    // This will fail with ReferenceError
    await getItems(dataConnect);
  5. Observe the error:

    ReferenceError: inputVars is not defined
    

[REQUIRED] Expected behavior

The generated code should pass undefined (or omit the parameter) for operations with no variables:

Expected (Working) Code:

function getItems(dcOrOptions, options) {
  const { dc: dcInstance, options: inputOpts} = validateAdminArgs(connectorConfig, dcOrOptions, options, undefined);
  dcInstance.useGen(true);
  return dcInstance.executeQuery('GetItems', undefined, inputOpts);  // ✅ undefined instead of inputVars
};

Alternative (also correct): Use the 2-argument overload:

function getItems(dcOrOptions, options) {
  const { dc: dcInstance, options: inputOpts} = validateAdminArgs(connectorConfig, dcOrOptions, options, undefined);
  dcInstance.useGen(true);
  return dcInstance.executeQuery('GetItems', inputOpts);  // ✅ 2-argument form
};

[REQUIRED] Actual behavior

Error Message:

ReferenceError: inputVars is not defined
    at getItems (generated/admin/index.cjs.js:34:51)
    at async main (index.js:10:18)

Debug Output:
When running with --debug, the Firebase CLI generates the SDK without errors, but the generated code itself contains the bug. The issue is in the code generator template, not the CLI execution.


Activity

  1. added
    api: dataconnect
    on Nov 12, 2025
  2. aalej commented on Nov 12, 2025

    @aalej
    Contributor

    Thanks for the detailed report @jdiekhoff, this is appreciated! I was able to reproduce the issue and it does seem like there's an error in the generated code. I'll raise this to our engineering team so they can take a look.

    sharing mcve here https://github.com/aalej/issues-9449

  3. aalej commented on Nov 17, 2025

    @aalej
    Contributor

    I'll go ahead and close this, this issue should be fixed by #9454 which is included in the firebase-tools v14.25.0 release. Also did a quick test to verify the fix https://github.com/aalej/issues-9449?tab=readme-ov-file#post-fix-14250.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: dataconnectreproducibletype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions