Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions:delete fails to match function name unless dot notation is used #5290

Closed
twaddington opened this issue Dec 1, 2022 · 1 comment · Fixed by #5292
Closed

functions:delete fails to match function name unless dot notation is used #5290

twaddington opened this issue Dec 1, 2022 · 1 comment · Fixed by #5292

Comments

@twaddington
Copy link
Contributor

Environment info

firebase-tools: 11.16.1
Platform: macOS 12.6.1

Test case

// index.ts
export * as foo from "./providers/foo.js";

// foo.ts
export const bar = functions.pubsub
  .schedule("every day 09:00")
  .onRun(async () => {
    console.log("Hello Firebase");
    return null;
  });

Steps to reproduce

// Fails with error
$ firebase functions:delete foo-bar
Error: The specified filters do not match any existing functions in project.

// Works as expected
$ firebase functions:delete foo.bar
...

// Deploy works the same with either wording
$ firebase deploy --only functions:foo-bar
$ firebase deploy --only functions:foo.bar

Expected behavior

The command firebase functions:delete foo-bar should succeed since that's how the function name appears when listed via firebase functions:list.

Actual behavior

The command firebase functions:delete foo-bar fails with an error.

@twaddington twaddington added the bug label Dec 1, 2022
@twaddington
Copy link
Contributor Author

From poking around the source it looks like the problem is here:

const context: args.Context = {
projectId: needProjectId(options),
filters: filters.map((f) => ({ idChunks: f.split(".") })),
};

The deployment command uses a different parsing function here:

export function parseFunctionSelector(selector: string): EndpointFilter[] {
const fragments = selector.split(":");
if (fragments.length < 2) {
// This is a plain selector w/o codebase prefix (e.g. "abc" not "abc:efg") .
// This could mean 2 things:
//
// 1. Only the codebase selector (i.e. "abc" refers to a codebase).
// 2. Id filter for the DEFAULT codebase (i.e. "abc" refers to a function id in the default codebase).
//
// We decide here to create filter for both conditions. This sounds sloppy, but it's only troublesome if there is
// conflict between a codebase name as function id in the default codebase.
return [
{ codebase: fragments[0] },
{ codebase: DEFAULT_CODEBASE, idChunks: fragments[0].split(/[-.]/) },
];
}
return [
{
codebase: fragments[0],
idChunks: fragments[1].split(/[-.]/),
},
];
}

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

Successfully merging a pull request may close this issue.

3 participants