fix(sdk-generators): always emit function metadata provider and executor#3446
Open
jviau wants to merge 3 commits into
Open
fix(sdk-generators): always emit function metadata provider and executor#3446jviau wants to merge 3 commits into
jviau wants to merge 3 commits into
Conversation
The source-generated IFunctionMetadataProvider and executor were skipped when an app declared zero (valid) functions, causing the worker to fall back to DefaultFunctionMetadataProvider, which throws because the new SDK does not produce a functions.metadata file. The generators now always emit, even when there are no functions, all declared functions fail validation, or duplicate function names are detected. Apps with validation errors still fail the build via the existing error diagnostics, so the emitted provider never ships; at runtime the broken default fallback is now unreachable. Fixes #3418
6877187 to
b7b660d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the .NET isolated worker SDK source generators to always emit a generated IFunctionMetadataProvider and IFunctionExecutor, ensuring function apps built with the new SDK can start successfully even when zero functions are declared (avoiding the runtime fallback to DefaultFunctionMetadataProvider, which expects a functions.metadata file).
Changes:
- Removed early-return guards so the metadata provider and executor generators always emit source, even for empty apps or apps with only invalid/duplicate functions.
- Added a new
NoFunctionsTestssuite and updated existing diagnostic tests to expect the now-emitted provider/executor outputs. - Added a release note describing the behavioral change and linking it to #3418.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Sdk.Generator.Tests/FunctionMetadataProvider/NoFunctionsTests.cs | Adds baseline expected output strings and a test verifying an empty metadata provider is emitted when no functions exist. |
| test/Sdk.Generator.Tests/FunctionMetadataProvider/EventHubsBindingsTests.cs | Updates invalid-binding test expectations to account for always-emitted provider output. |
| test/Sdk.Generator.Tests/FunctionMetadataProvider/DiagnosticResultTests.cs | Updates diagnostic tests (invalid bindings, duplicates) to expect generated provider output rather than “no generation”. |
| test/Sdk.Generator.Tests/FunctionExecutor/FunctionExecutorGeneratorTests.cs | Adds a new executor test case for “no functions” to validate always-emitted executor output. |
| sdk/Sdk.Generators/FunctionMetadataProviderGenerator/FunctionMetadataProviderGenerator.cs | Removes zero-functions/duplicate-name early returns; always emits generated metadata provider. |
| sdk/Sdk.Generators/FunctionExecutor/FunctionExecutorGenerator.cs | Removes zero-functions early return; always emits generated function executor. |
| sdk/release_notes.md | Adds release note entry describing always-emitted provider/executor behavior for empty/invalid apps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reword the generated provider comment to avoid implying invalid-function apps can never ship the provider. Error diagnostics can be configured via .editorconfig, but they still fail the build by default.
Update the executor generator comment to describe source emission rather than runtime registration. Runtime registration still depends on the auto-register build property and/or user wiring.
kshyju
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue describing the changes in this PR
resolves #3418
Function apps built with the new SDK threw at function-indexing time when they declared zero functions. The source-generated
IFunctionMetadataProvider(and executor) were skipped when no valid functions were found, so the worker fell back toDefaultFunctionMetadataProvider, which throws because the new SDK does not emit afunctions.metadatafile.This change makes both source generators always emit, even when:
Apps with validation errors still fail the build via the existing error diagnostics (duplicate names, invalid bindings, etc.), so the emitted provider never ships in a broken app. The key benefit is that the broken
DefaultFunctionMetadataProviderfallback is now unreachable at runtime, so a genuinely empty app starts successfully.To support this, the previous early-return guards were removed from
FunctionMetadataProviderGenerator(zero-function and duplicate-name gates) andFunctionExecutorGenerator(zero-method gate). The diagnostic reporting itself is unchanged.Pull request checklist
release_notes.mdAdditional information
Added a new
NoFunctionsTestssuite verifying the empty-provider output and aNoFunctionsexecutor test. Updated the existing diagnostic tests (InvalidRetryOptionsFailure,MultipleHttpResponseBindingsFails,MultipleOutputBindingsOnMethodFails,MultipleOutputBindingsOnPropertyFails,CardinalityManyWithNonIterableInputFails, and bothDuplicateFunctionNames*tests) to expect the now-emitted provider source instead of asserting no generation. Full generator suite passes: 431 passed, 0 failed.