New API - #806
Conversation
TomasKorbar
commented
Sep 8, 2026
- Add HTTP API server for submitting consolidation jobs
- Add Jira webhook command endpoint for bot-mention dispatching
347b96b to
e0072e2
Compare
nforro
left a comment
There was a problem hiding this comment.
It seems there are some missing pieces, here are some LLM findings:
-
P1: Public unauthenticated job submission
ymir/api/consolidation.py:80-97,146-148exposes/api/consolidationwithout authentication throughopenshift/route-api.yml. Anyone reaching the route can enqueue costly arbitrary workflows. Additionally, webhook authentication fails open whenJIRA_WEBHOOK_SECRETis unset (ymir/api/jira_webhook.py:65-69). Authentication should cover every mutating endpoint and fail closed. -
P1: API image is never published
openshift/imagestream-api.yml:10importsquay.io/jotnar/ymir-api:latest, but.github/workflows/build-and-push.ymlhas no job publishingContainerfile.api. After merge, deployment will receive no new API image. -
P1: Deployment requires an undocumented secret
openshift/deployment-api.yml:50-51references mandatory secretapi-env, butopenshift/README.md:11-46neither documents nor creates it. Unless provisioned out-of-band, the pod remains inCreateContainerConfigError. -
P2: None of the 30 API tests run in CI
Makefile.tests:29-52enumerates existing package test directories but omitsymir/api/tests. Current green checks therefore provide no test coverage for the new server. -
P2:
source_issuesaccepts invalid cardinalitiesymir/api/consolidation.py:31,109accepts zero, one, or more than two issues, although consolidation operates on a pair. One issue queues a successful no-op; more than two populates all branches whileymir/agents/prompts/mr_consolidation/prompt.j2:7-13describes only the first two. Constrain this to exactly two entries when supplied.
Introduce a lightweight aiohttp-based API server (ymir/api/) that accepts POST requests to enqueue MR consolidation jobs into the existing Redis hash queue. - ymir/api/server.py: Generic API server with /healthz and pluggable route modules. Manages Redis lifecycle via redis_client(). - ymir/api/consolidation.py: POST /api/consolidation endpoint supporting auto mode (source_issues=null, dedup-safe) and label-triggered mode (source_issues set, returns 409 on conflict). - Containerfile.api: Minimal Fedora 44 container image. - compose.yaml: New 'api' service on port 8080 in agents profile. - OpenShift manifests: Deployment, Service, Route, ImageStream. - 13 unit tests covering both modes, validation, dedup, and errors. Co-authored-by: Cursor <cursoragent@cursor.com>
Add a generic POST /api/jira/webhook endpoint that parses Jira comment_created webhook payloads, detects bot mentions by account ID, and dispatches commands via an extensible command registry. - ymir/api/command_parser.py: Command registry with register() and dispatch(). New commands = one handler + one register() call. - ymir/api/jira_webhook.py: Webhook endpoint with X-Webhook-Secret validation, comment_created filtering, and [~accountId:] mention detection. - ymir/api/consolidation.py: Added handle_consolidate_command with argparse-based CLI parsing, registered as 'consolidate' command. Refactored shared _submit_consolidation_job() for reuse. - ymir/api/app_keys.py: Extracted REDIS_KEY to break circular imports. - Env vars: JIRA_WEBHOOK_SECRET, JIRA_BOT_ACCOUNT_ID added to compose.yaml and OpenShift deployment. - 17 new unit tests (command parser + webhook), 30 total. Co-authored-by: Cursor <cursoragent@cursor.com>
e0072e2 to
4f41782
Compare
Yeah there is no authentication, but the service is accessible only from internal network and ymir_todo can be placed by essentially anyone, so i am not sure whether implementing authentication is necessary/useful here.
ah missed this. Did not know where to put it. Will fix.
Ah will add info to documentation.
Dammit.
Right. Makes sense. |
- Fail closed when JIRA_WEBHOOK_SECRET is unset: return HTTP 500 instead of skipping authentication entirely. - Add build-and-push-api job to the CI workflow so the ymir-api image is actually published to quay.io. - Document the api-env secret in openshift/README.md. - Add check-api and check-api-in-container targets to Makefile.tests so the API tests run in CI. - Constrain source_issues to exactly 2 entries via a Pydantic field_validator and tighten argparse nargs from '+' to 2. Co-authored-by: Cursor <cursoragent@cursor.com>
You also need to create the repo on quay.io. |
|
thanks a lot for kickstarting this! As for the current code, I have few findings with the help of Codex, worth double-checking:
I also wanted to bring up the Ymir triggering rearchitecture research here too (https://github.com/packit/research/blob/00a812858e100da0d7fb124d3b83220de990af19/research/ymir-triggering-rearchitecture/index.md) - the approach here uses webhooks, but I remember we were seriously considering also Automation + event router, with manual trigger forms. This choice affects authentication, payload format, authorization, deduplication, and UX. This would be worth re-descussing on arch. Considering that, we could split this PR into the API foundation and then the followup integration, wdyt? With that, the API foundation could still be tested standalone. The initial research also showed the current OpenShift route may not be reachable from Jira directly, we would need to consider alternatives for that case: simple Ymir dashboard, polling, ..? |