Skip to content

fix(sdk-generators): always emit function metadata provider and executor#3446

Open
jviau wants to merge 3 commits into
mainfrom
u/jviau/sdk/fix-zero-func
Open

fix(sdk-generators): always emit function metadata provider and executor#3446
jviau wants to merge 3 commits into
mainfrom
u/jviau/sdk/fix-zero-func

Conversation

@jviau

@jviau jviau commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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 to DefaultFunctionMetadataProvider, which throws because the new SDK does not emit a functions.metadata file.

This change makes both source generators always emit, even when:

  • the app declares zero functions,
  • every declared function fails validation, or
  • duplicate function names are detected.

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 DefaultFunctionMetadataProvider fallback 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) and FunctionExecutorGenerator (zero-method gate). The diagnostic reporting itself is unchanged.

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Added a new NoFunctionsTests suite verifying the empty-provider output and a NoFunctions executor test. Updated the existing diagnostic tests (InvalidRetryOptionsFailure, MultipleHttpResponseBindingsFails, MultipleOutputBindingsOnMethodFails, MultipleOutputBindingsOnPropertyFails, CardinalityManyWithNonIterableInputFails, and both DuplicateFunctionNames* tests) to expect the now-emitted provider source instead of asserting no generation. Full generator suite passes: 431 passed, 0 failed.

Copilot AI review requested due to automatic review settings July 1, 2026 21:51
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
@jviau jviau force-pushed the u/jviau/sdk/fix-zero-func branch from 6877187 to b7b660d Compare July 1, 2026 21:52

Copilot AI 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.

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 NoFunctionsTests suite 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.

Comment thread sdk/Sdk.Generators/FunctionExecutor/FunctionExecutorGenerator.cs Outdated
jviau added 2 commits July 1, 2026 15:30
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.
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.

[SDK] Apps do not work with 0 functions declarations

3 participants