Skip to content

onSchedule() with string parameter creates Cloud Scheduler jobs with incorrect v1 URLs instead of v2 Cloud Run URLs #1734

Open

Description

@zhendalf

[REQUIRED] Environment info

firebase-functions: 6.4.0
firebase-tools: 14.16.0
Platform: macOS (Darwin 25.0.0)

[REQUIRED] Test case

import { onSchedule } from 'firebase-functions/v2/scheduler'

// This FAILS - creates scheduler with wrong URL format
export const failingScheduler = onSchedule(
  'every 1 minutes',
  async () => {
    console.log('This function gets PERMISSION_DENIED')
  }
)

// This WORKS - creates scheduler with correct URL
export const workingScheduler = onSchedule(
  {
    schedule: 'every 1 minutes', 
    timeZone: 'America/Los_Angeles',
  },
  async () => {
    console.log('This function works correctly')
  }
)

[REQUIRED] Steps to reproduce

  1. Create a v2 scheduled function using the string parameter syntax
  2. Deploy with firebase deploy --only functions
  3. Check Cloud Scheduler console
  4. Observe the scheduler job has URL: https://us-central1-PROJECT.cloudfunctions.net/FUNCTION_NAME (v1 format)
  5. Function execution fails with PERMISSION_DENIED

[REQUIRED] Expected behavior

Both syntaxes should create Cloud Scheduler jobs with the correct v2 Cloud Run URLs (format: https://FUNCTION_NAME-HASH-uc.a.run.app/)

[REQUIRED] Actual behavior

When using the string parameter syntax, Cloud Scheduler jobs are created with v1 function URLs that don't exist, causing PERMISSION_DENIED errors.

Cloud Scheduler shows:

  • Functions with string syntax: URL points to cloudfunctions.net (v1) - FAILS
  • Functions with object syntax: URL points to run.app (v2) - WORKS

Analysis

The TypeScript types allow both signatures:

onSchedule(schedule: string, handler: Function)
onSchedule(options: ScheduleOptions, handler: Function)

However, only the object syntax properly configures the Cloud Scheduler job with the correct Cloud Run URL. This is a critical bug because:

  1. The types suggest both are valid
  2. The deployment succeeds without warnings
  3. The error only appears at runtime when scheduler tries to invoke the function
  4. The error message (PERMISSION_DENIED) doesn't indicate the root cause is a URL mismatch

Workaround

Always use the object syntax with explicit schedule and timeZone properties:

onSchedule({
  schedule: 'every 1 minutes',
  timeZone: 'America/Los_Angeles',
}, handler)

Related Issues

This appears related to:

Activity

  1. google-oss-bot commented on Sep 25, 2025

    @google-oss-bot
    Collaborator

    I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

  2. cabljac commented on Sep 29, 2025

    @cabljac
    Contributor

    Hi! Thanks for raising this. It's been received and we will provide updates when available.

  3. deleted a comment from HassanBahati on Jan 8, 2026
  4. cabljac commented on Jan 8, 2026

    @cabljac
    Contributor

    Hi all, we've been investigating and have not been able to reproduce the permissions part of this so far

    But we have managed to reproduce the URL issue

    Marked this for continued investigation.

  5. cabljac commented on Feb 23, 2026

    @cabljac
    Contributor

    Hi there

    Image

    According to the docs, your function will receive BOTH a run.app and a cloudfunctions.net URL:

    https://docs.cloud.google.com/functions/docs/deploy

    Observe the scheduler job has URL: https://us-central1-PROJECT.cloudfunctions.net/FUNCTION_NAME (v1 format)

    I think this is expected. you can use

    gcloud run services describe FUNCTION_NAME --region us-central1 --format 'value(status.url)' --project=PROJECT

    to get the run.app domain URL.

    Function execution fails with PERMISSION_DENIED

    We'll continue investigating and try to reproduce this error, thanks for your patience!

  6. added
    needs-author-feedback
    on Feb 23, 2026
  7. HassanBahati commented on Feb 23, 2026

    @HassanBahati
    Contributor

    Hi there,

    We were unable to reproduce this issue as our function wasn't returning a PERMISSION_DENIED. Could you please confirm if our setup in this MRE matches what you had.

    Cheers

  8. added
    reproduced
    and removed
    unable to reproduce
    on Jul 2, 2026
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

    bugneeds-author-feedbackreproduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions