Skip to content

feat: warn on dev version and loop detection - #664

Merged
uniqueg merged 4 commits into
devfrom
feat/624-startup-warnings
Nov 4, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/624-startup-warnings

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Two startup warnings:

  • The service info reports the placeholder version 0.0.0.dev0.
  • A gateway has neither server.public_url nor plugins.gateway_id, so loop detection is inactive. The check uses the name the host ends up with, so a public URL from which no valid name can be derived warns too.

Docs: service info configuration, deployment guide (list of startup warnings), plugins page.

Closes #624

Light lane: only trivial startup warnings, with tests.

Verification

  • ruff check, ruff format --check, mypy, ast-grep scan, mkdocs build --strict: pass.
  • coverage run -m pytest with MongoDB 7.0: 3380 passed, 1 skipped, 100% coverage.
  • CI: see the checks of this PR.

🤖 Generated with Claude Code

Summary by Sourcery

Warn operators about unreleased service versions and disabled gateway loop detection during startup.

Enhancements:

  • Add startup warnings when service info uses the unreleased placeholder version or gateway loop detection lacks a gateway name.
  • Document the new startup warnings in service information, deployment, and gateway plugin guidance.

Tests:

  • Add coverage for placeholder-version warnings and gateway loop-detection warning conditions.

Log a warning on startup if the service info reports the placeholder
version 0.0.0.dev0, and if a gateway has neither server.public_url nor
plugins.gateway_id, so that it can't detect routing loops. Until now,
only the docs said the latter.

Closes #624

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v0.21.0 milestone Nov 4, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Adds two non-blocking startup warnings: one for the 0.0.0.dev0 service version and one for gateways that cannot derive a name for Via-header loop detection. The implementation validates the resolved runtime values, provides actionable configuration guidance, adds focused tests for warning conditions and alternatives, and documents the behavior.

Sequence diagram for startup configuration warnings

sequenceDiagram
    participant App as Application startup
    participant Runtime as Runtime configuration
    participant ServiceInfo as Service info
    participant Gateway as Gateway
    participant Logger as Startup logger

    App->>ServiceInfo: check_service_info(app)
    ServiceInfo->>Logger: warning when version is 0.0.0.dev0
    App->>Runtime: create_host()
    Runtime-->>Gateway: resolved host.gateway_id
    alt gateway_id is absent
        Gateway->>Logger: warning that routing loops are not detected
    end
    App-->>App: continue startup
Loading

Flow diagram for gateway loop-detection identity

flowchart TD
    Start[Gateway startup] --> Host["create_host()"]
    Host --> Identity{host.gateway_id exists?}
    Identity -->|Yes| Detection[Enable Via-header loop detection]
    Identity -->|No| Warning[Log startup warning]
    Warning --> Inactive[Loop detection remains inactive]
Loading

File-Level Changes

Change Details Files
Warn when service metadata still uses the unreleased placeholder version.
  • Define the 0.0.0.dev0 placeholder constant.
  • Extend service-info startup validation to log an actionable warning while allowing startup to continue.
  • Add tests covering both warning and non-warning version values.
foca/api/service_info.py
tests/api/test_service_info.py
docs/configuration/service-info.md
docs/deployment.md
Warn gateway applications when loop detection has no usable gateway identity.
  • Check the runtime-derived gateway host name during app creation.
  • Log configuration guidance when neither server.public_url nor plugins.gateway_id yields an identity.
  • Cover missing, public-URL, and explicit-ID configurations with parametrized tests.
foca/foca.py
tests/plugins/test_plugin_runtime.py
docs/deployment.md
docs/plugins.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4ab71dd) to head (f7fee19).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #664   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         7223      7228    +5     
=========================================
+ Hits          7223      7228    +5     
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 4, 2026 03:13

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/api/test_service_info.py" line_range="333" />
<code_context>
+def test_check_service_info_released_version(log: pytest.LogCaptureFixture) -> None:
+    """Other versions are not warned about."""
+    check_service_info(_app({"service": {**DEPLOYED, "version": "1.2.3.dev0"}}))
+    assert PLACEHOLDER_VERSION not in log.text


</code_context>
<issue_to_address>
**Other versions still trigger warnings**

When `check_service_info` emits a warning for `1.2.3.dev0` without the phrase `placeholder version`, `test_check_service_info_released_version` checks only whether the log contains `placeholder version`; a warning for `1.2.3.dev0` with different wording therefore passes, despite the test claiming other versions are not warned about.

Assert that the captured log has no records at `logging.WARNING` level.
</issue_to_address>

Linked issues

#624 feat: warn on dev version and loop detection · 3 of 3 met

# Requirement Status Notes
1 Warn when service info reports the placeholder version 0.0.0.dev0. ✅ Met The startup service-info check logs a warning when the version matches 0.0.0.dev0.
2 Warn when a gateway has neither server.public_url nor plugins.gateway_id, leaving loop detection inactive. ✅ Met Startup checks the created host’s gateway_id, so it also warns when a public URL cannot produce a valid gateway name.
3 Test each warning and cases where no warning should occur, with 100% coverage. ✅ Met Tests cover both warnings and non-warning cases; the project requires 100% coverage, and the PR verification reports 100%.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/api/test_service_info.py:333


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/api/test_service_info.py Resolved

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit e0ee433 into dev Nov 4, 2026
56 checks passed
@uniqueg
uniqueg deleted the feat/624-startup-warnings branch November 4, 2026 04:07
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.

feat: warn on dev version and loop detection

1 participant