Skip to content

Fix kit source and prefix validation when sharing source directory - #11253

Merged
shettyvarun268 merged 4 commits into
mainfrom
shettyvarun268/fix-kit-source-prefix-validation
Oct 12, 2026
Merged

shettyvarun268 merged 4 commits into
mainfrom
shettyvarun268/fix-kit-source-prefix-validation

Conversation

@shettyvarun268

Copy link
Copy Markdown
Contributor

Description

Fixes an issue where installing a local Function Kit into a directory that is already configured as a functions codebase in firebase.json (for example, firebase functions:kits:install --directory functions) causes subsequent firebase commands to fail validation with:

More than one functions config specifies the same source directory ('functions') and prefix ('').

In assertUniqueSourcePrefixPair (src/functions/projectConfig.ts), kit configs (isKitConfig(c)) previously defaulted to c.prefix || "" ("") even though kit configurations do not allow a top-level prefix field and instead automatically prefix each instance with addKitPrefix(instanceId) (kit-<instanceId>) during config expansion.

This change:

  • Updates assertUniqueSourcePrefixPair to resolve kit prefixes per instance via addKitPrefix(instanceId) (kit-<instanceId>).
  • Runs assertUniqueKitInstancesAndCodebases before assertUniqueSourcePrefixPair in validate() so duplicate kit instance IDs across kits sharing a source directory continue to report the duplicate-instance error first.

Scenarios Tested

  • Unit tests in src/functions/projectConfig.spec.ts:
    • A local codebase ({ source: "functions", codebase: "default" }) and a kit config sharing source: "functions" pass validation.
    • Multiple kit configs with distinct instance IDs sharing the same source directory pass validation.
    • A local codebase with an explicit prefix that matches a kit instance's resolved prefix (kit-<instanceId>) on the same source directory fails validation.

Sample Commands

firebase functions:kits:install --directory functions

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request resolves an issue where a Function Kit and a functions codebase sharing the same source directory failed firebase.json validation. It updates the validation logic in assertUniqueSourcePrefixPair to correctly extract and check prefixes for kit instances, and adds comprehensive unit tests. The review feedback points out that the error message in assertUniqueSourcePrefixPair should be updated to provide accurate remediation guidance, since specifying a prefix is forbidden in a Function Kit configuration.

Comment thread src/functions/projectConfig.ts
@shettyvarun268
shettyvarun268 force-pushed the shettyvarun268/fix-kit-source-prefix-validation branch 3 times, most recently from f714300 to 5bd2662 Compare October 9, 2026 18:27
@shettyvarun268
shettyvarun268 marked this pull request as ready for review October 9, 2026 18:45
Comment thread src/functions/projectConfig.ts Outdated
Comment thread src/functions/projectConfig.spec.ts Outdated
Comment thread src/functions/projectConfig.spec.ts Outdated
@shettyvarun268
shettyvarun268 force-pushed the shettyvarun268/fix-kit-source-prefix-validation branch from 5bd2662 to b237b01 Compare October 9, 2026 21:23
@shettyvarun268
shettyvarun268 merged commit afc3539 into main Oct 12, 2026
51 checks passed
@shettyvarun268
shettyvarun268 deleted the shettyvarun268/fix-kit-source-prefix-validation branch October 12, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants