Skip to content

Plain Foca(...) clears the gateway settings #517

Closed

Description

@uniqueg

Problem

Found in the pre-release review of FOCA v0.18.0.

foca.plugins.runtime.configure() keeps one GatewayApp for the whole process, and every Foca(...) calls it, also those without gateway=. It refuses other settings only while a host is cached, and create_app() closes the host it creates for its startup check. So, until the first gateway request, any later Foca(...) overwrites the settings, and one without gateway= clears them. After that, create_app() and get_host() raise RuntimeError: No gateway app configured: pass Foca(gateway=...), although gateway= was passed.

Also:

  • whether a GatewayApp with other settings is refused depends on whether a host exists, i.e., on import order;
  • create_host(), plugin_classes() and get_backend_list() read the configuration of the most recently created FOCA app (get_config() "latest"), which may be another app's (e.g., a Celery worker module's);
  • docs/plugins.md does not say that every Foca(...) in a gateway process must pass the same GatewayApp.

Scenario (proTES)

pro_tes/celery_worker.py creates a module-level Foca(config_file=...) without gateway=; Connexion imports it (via the TES controllers and track_task_progress) during create_app(). If proTES passes gateway= only in app.py, create_app() fails; if the import happened later, the first gateway request returns a 500.

Proposed fix

  • Bind the gateway settings to the configuration of the Foca(gateway=...) instance that sets them; Foca(...) without gateway= leaves them alone.
  • Refuse other gateway settings in the same process whether or not a host exists (only foca.plugins.runtime.reset() clears them).
  • Build hosts and backend lists from the bound configuration, not the latest one.
  • Document the rules in docs/plugins.md.
  • Regression tests: gateway Foca then plain Foca; other GatewayApp settings; latest configuration of another app.

Activity

  1. added this to the v0.18.0 milestone on Oct 26, 2026
  2. added
    priority: medium
    status: in progress
    type: bug
    workload: hours
    on Oct 26, 2026
  3. removed
    status: in progress
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: bugworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions