Skip to content

refactor!: process tasks with FOCA plugins #333

Closed

Description

@uniqueg

Part of #321: steps 2 "Engine", 3 "Routing and forwarding", 5 "Config" (plugins section, custom.middlewares refused), 7 "Tags", 8 "Deleted", 9 "Errors", 11 "Docs" and 12 "Tests", as decided there. Provenance and the chart's plugins values are separate children.

Problem

proTES runs its own middleware engine (pro_tes/middleware/), and the routing result travels inside the task body (tes_urls).

Proposal

As in #321:

  • proTES declares itself a gateway (Foca(..., gateway=GatewayApp(api="tes", validate=..., sanitize=..., backends=...)), shared with the Celery worker module); POST /tasks builds the inbound request and principal with foca.plugins.adapter in the controller and passes them to TaskRuns.create_task(), which stays free of Flask; _apply_middlewares() is replaced by run = get_host().start(...), run.request() and run.route(...); validate = TesTask and tes.Task, sanitize = URL credential stripping and the inline content limit; order of the security checks unchanged.
  • The forward loop runs over run.attempts(candidates); TesClient sends each OutboundRequest and adds the backend's credentials after the plugins; outcomes map as in refactor!: run task plugins with FOCA #321 (not accepted → next; outcome unknown → stop, SYSTEM_ERROR; ForwardTimeout/NoBackendAvailable → 503).
  • Default pipeline foca.routing.ordered; custom.middlewares refused by FOCA with its hint.
  • Tags: client tags kept in the stored task; no gateway.* key in the relayed task (strip_for_forwarding); other client gateway.* keys → 400.
  • Deleted: pro_tes/middleware/, pro_tes/plugins/middlewares/, MiddlewareException, InvalidMiddleware, geopy and its mypy override, the tes_urls handling.
  • FOCA's problem types in exceptions.mapping.
  • Docs: docs/middleware.md becomes docs/plugins.md (operator view); API, access control, operations pages; "Upgrading" (routing change: ordered failover instead of distance-then-random, no third-party lookups by default; random and distance routing in foca-plugins).
  • Tests with fake plugins via FOCA's fake_plugin_entry_points fixture; every forward outcome; 100% coverage; ast-grep: no Flask, Werkzeug or Connexion import in pro_tes/ outside app.py, server.py and exceptions.py.

Acceptance criteria

The acceptance criteria of #321 except provenance and the chart's plugins values.

Activity

  1. added
    priority: high
    status: blocked
    type flag: breaking change
    type: maintenance
    on Oct 28, 2026
  2. added
    type: security
    workload: days
    on Oct 28, 2026
  3. added
    status: triage
    status: in progress
    and removed
    status: blocked
    status: triage
    on Oct 29, 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: highstatus: in progresstype flag: breaking changetype: maintenancetype: securityworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions