Skip to content

feat: check the service info's environment - #348

Merged
uniqueg merged 2 commits into
devfrom
feat/check-service-info-environment
Nov 3, 2026
Merged

uniqueg merged 2 commits into
devfrom
feat/check-service-info-environment

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

The app now refuses to start if the environment of its service info (service_info.service.environment) isn't one of the values allowed for services (custom.endpoints.services.environments), with an error naming both settings.

  • An empty list allows any value, and a service info without environment (also null in an overlay) passes, as for services. Values are compared case-sensitively, also as for services.
  • Defaults: dev is in the default list, so the defaults pass and nothing changes for deployments that changed neither setting. Deployments with a mismatch no longer start; the configuration guide, chart README, upgrade notes and release notes say so. The example of allowed environments in the configuration guide now also sets the service info's environment.

Closes #346

How it was verified

  • coverage run --source cloud_registry,scripts -m pytest, mongomock: 1969 passed, 11 skipped, before the last small test and docs commit. The local coverage report was unreliable, as I edited a docstring of cloud_registry/app.py during the run (line numbers shifted).
  • CI on the final commit: all jobs passed, including Test (mongomock) with its 100 % coverage gate and Test (MongoDB 7.0).
  • MONGODB_TEST_URI=... pytest tests/ga4gh tests/test_app.py against mongo:7.0 in a container: passed.
  • pre-commit run on the changed files: passed; mkdocs build --strict: passed; version guard (tests/test_version_mentions.py): passed.
  • adversarial-reviewer and quality-reviewer: three low findings, all fixed; light lane wasn't used.

Declined review findings

None.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Ensure the service info environment matches the environments permitted for registered services before starting the application.

New Features:

  • Validate that the service info environment is allowed by the configured service environments before startup.

Enhancements:

  • Allow empty environment lists and unset service-info environments to remain valid, consistent with service validation.
  • Provide startup errors that identify both mismatched configuration settings.

Documentation:

  • Document the new startup validation, defaults, upgrade considerations, and matching configuration examples.

Tests:

  • Add coverage for valid, unset, case-sensitive invalid, and app-startup environment validation scenarios.

uniqueg and others added 2 commits November 3, 2026 21:31
Refuse to start if the environment of the service info isn't one of the
values allowed for services, with an error naming both settings. An
empty list allows any value, and a service info without `environment`
passes, as for services. The defaults pass (`dev` is in the default
list), so only deployments that changed one of the two are affected.

Closes #346

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Set the service info's environment in the example of allowed
environments, as the app refuses to start otherwise. Parametrize the test
of allowed environments, and wrap the changed paragraph.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v1.0.0-rc2 milestone Nov 3, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR adds an app-startup guard ensuring service_info.service.environment is compatible with custom.endpoints.services.environments, with deliberate handling for empty allowlists and missing/null values, comprehensive tests, and synchronized operator documentation.

Sequence diagram for service environment startup validation

sequenceDiagram
    participant App
    participant ServiceInfo as service_info
    participant Config as custom_config

    App->>ServiceInfo: check_service_info_environment()
    ServiceInfo->>Config: get_custom_config(CustomConfig)
    Config-->>ServiceInfo: environments
    alt environment is missing or null
        ServiceInfo-->>App: return
    else environments is empty
        ServiceInfo-->>App: return
    else environment is in environments
        ServiceInfo-->>App: return
    else environment is not allowed
        ServiceInfo-->>App: raise RuntimeError
    end
Loading

File-Level Changes

Change Details Files
Add startup validation that the registry service info environment is allowed by the configured service environments.
  • Introduce a context-aware check that permits missing/null environments and empty allowlists, while enforcing case-sensitive membership otherwise.
  • Invoke the check during app creation and report both configuration paths in failures.
  • Add focused unit and app-startup tests for allowed, omitted, null, arbitrary, case-sensitive, and empty-string values.
cloud_registry/ga4gh/registry/service_info.py
cloud_registry/app.py
tests/ga4gh/registry/test_service_info.py
tests/test_app.py
Update configuration defaults and operator documentation to explain the new startup compatibility requirement.
  • Document that the service info environment must be included in the service allowlist and that defaults remain compatible.
  • Update the configuration example to set both related values.
  • Add deployment, upgrade, and release-note guidance for mismatched settings.
cloud_registry/config.yaml
docs/configuration.md
deployment/README.md
docs/upgrading.md
docs/releases/1.0.0rc2.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 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5d73085) to head (ae459f9).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #348   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         2426      2436   +10     
=========================================
+ Hits          2426      2436   +10     

☔ 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 3, 2026 20:46

@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 reviewed your changes and they look great!

Linked issues

#346 feat: check the environment of the service info · 3 of 3 met

# Requirement Status Notes
1 Refuse to start when the service info environment is not allowed, with an error naming both settings. ✅ Met The startup check raises a RuntimeError naming both settings and is called during app creation.
2 Allow any environment when the list is empty, and allow service info without an environment. ✅ Met The check returns for an empty allowed list or a missing/null environment.
3 Explain the defaults and the mismatch impact in the docs and upgrade notes. ✅ Met The docs and upgrade notes state that the defaults pass and deployments with a mismatch must adjust their configuration.

Sourcery assessment

Needs a human reviewer. A deployment whose allowed service environments omit the service-info environment will now abort app startup, leaving the service unavailable until the config is changed or the code is rolled back. Reverting restores the prior startup behavior, but cannot undo any downtime already incurred.


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

@uniqueg
uniqueg merged commit 8b83f1e into dev Nov 3, 2026
52 of 56 checks passed
@uniqueg
uniqueg deleted the feat/check-service-info-environment branch November 3, 2026 21:00
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: check the environment of the service info

1 participant