fix: reject deploy of dead services and gate release on CI#47
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds a CI job running Python 3.12, ruff lint/format checks, and pytest before release. Deploy endpoint now rejects services whose catalog ChangesRelease 47: CI Integration and Service Deprecation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/main.py (1)
775-782:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRun dead-service validation before worker resolution.
Line 777 resolves
worker_idbefore the dead-service guard (Lines 781-782). If workers are offline or multiple workers exist withoutworker_id, this endpoint can return unrelated 400/503 errors instead of the dead/discontinued rejection. Validatesvcandstatusfirst, then resolve worker.Suggested fix
`@app.post`("/api/deploy/{slug}") async def api_deploy(request: Request, slug: str, body: DeployRequest, worker_id: int | None = None) -> dict[str, str]: _require_writer(request) - worker_id = await _resolve_worker_id(worker_id) svc = catalog.get_service(slug) if not svc: raise HTTPException(status_code=404, detail=f"Service '{slug}' not found") if svc.get("status") == "dead": raise HTTPException(status_code=400, detail=f"Service '{slug}' is no longer available (dead/discontinued)") + worker_id = await _resolve_worker_id(worker_id)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/main.py` around lines 775 - 782, In api_deploy, the worker resolution (_resolve_worker_id) is being called before validating the service status, causing worker-related errors to surface instead of the intended dead-service rejection; reorder logic so that after calling catalog.get_service(slug) and checking svc is not None and verifying svc.get("status") != "dead" (the dead/discontinued guard), only then call worker_id = await _resolve_worker_id(worker_id); keep the existing _require_writer(request) at the top and preserve existing HTTPException responses and messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@app/main.py`:
- Around line 775-782: In api_deploy, the worker resolution (_resolve_worker_id)
is being called before validating the service status, causing worker-related
errors to surface instead of the intended dead-service rejection; reorder logic
so that after calling catalog.get_service(slug) and checking svc is not None and
verifying svc.get("status") != "dead" (the dead/discontinued guard), only then
call worker_id = await _resolve_worker_id(worker_id); keep the existing
_require_writer(request) at the top and preserve existing HTTPException
responses and messages.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d81eaefa-577e-4533-9caf-0bda6af5ee02
📒 Files selected for processing (3)
.github/workflows/release.ymlapp/main.pydocs/guides/peer2profit.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
=======================================
Coverage 96.58% 96.58%
=======================================
Files 24 24
Lines 2373 2375 +2
=======================================
+ Hits 2292 2294 +2
Misses 81 81
🚀 New features to boost your workflow:
|
Block deployment of services with status "dead" (e.g. peer2profit) with a 400 error. Add deprecation notice to peer2profit guide. Ensure the release workflow only publishes after lint and tests pass by adding a ci job dependency. Closes cp-gjea, cp-2wbv
…ip cache) - Change dead service response from 400 to 410 (Gone) for correct REST semantics - Add ruff to requirements-dev.txt instead of unpinned install in CI - Add pip cache to CI setup-python step - Add test for deploy of dead service returning 410
3157fe9 to
4ae66e4
Compare
Summary
status: deadin the deploy endpoint (/api/deploy/{slug}) with a 400 error, preventing users from deploying discontinued services like peer2profitdocs/guides/peer2profit.mdcijob thatreleasedepends on, preventing publishing before tests passTest plan
POST /api/deploy/peer2profitreturns 400 with appropriate messagereleasejob hasneeds: ciSummary by CodeRabbit
Bug Fixes
Documentation
Chores
Tests
Chores