Skip to content

fix(warnings): scope empty-discovery reason to the selected application object #380

Description

@yeongseon

Context

The empty-discovery warning emitted when a scanned app exposes no function builders is wrong in two places, not one. Reproduced on main (an app with no _function_builders, while another @openapi route is registered):

A function builder could not be built during discovery and was omitted from the spec:
no functions were discovered on the application object (Wrapper);
the generated spec will have empty paths

...while spec["paths"] == ['/api/decorated'].

Two false clauses:

  1. Back half (bridge.py:477-478) — "the generated spec will have empty paths". False: the process-wide registry can already hold paths from other decorated apps. (Original scope of this issue.)
  2. Front half (spec.py:790-792, _DISCOVERY_SKIPPED_MESSAGE) — "A function builder could not be built during discovery and was omitted from the spec". False: no builder failed to build; the app exposed zero builders. #376 reused the per-builder-failure add_discovery_warning channel for a different failure kind (app exposes nothing), so _collect_discovery_warnings prepends the builder-failure template to an app-level condition.

Fixing only the back half (as PR #384 currently does) still leaves the misleading front sentence.

Root cause

_collect_discovery_warnings (spec.py:857-864) unconditionally prepends _DISCOVERY_SKIPPED_MESSAGE to every recorded (function_name, reason). The app-level empty case (function_name is None) is semantically distinct from a builder-build failure but shares the same warning code and template.

Acceptance Checklist

  • Reword the bridge.py reason to claim only the observed fact — "no functions were discovered from the selected application object (<type>)" — no "empty paths" prediction.
  • Distinguish the app-level empty case from builder-build failure. Preferred: introduce a distinct WarningCode.EMPTY_DISCOVERY (own message template) so --fail-on-warnings users can tell the two apart; alternatively, branch _collect_discovery_warnings on function_name is None to skip the builder-failure prefix.
  • Leave final empty-paths determination to the CLI's post-generation spec check (cli.py:246,263), unchanged.
  • Fix the truncated iter_functions docstring at adapters/azure_functions.py:124-125 ("...so it is / empty list when...") — a sentence was dropped in the #376 merge (should read roughly "...so it is skipped rather than raising. Returns an empty list when the app exposes no builders...").
  • Update/adjust associated tests to assert the new wording and the distinct code.
  • Coverage stays >= 95%.

Out of scope

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Normal / later

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions