fix(backend): Python 3.13 固定で libsql segfault を回避+起動スモークテスト/再発防止#400
Conversation
Renovate が base image を python:3.14 に上げた結果、libsql-experimental (sqlalchemy-libsql 経由)が 3.14 未対応でマイグレーション時に segfault (exit 139)し api が起動ループしていた。 - backend/Dockerfile: builder/runtime を python:3.13-slim に戻す - .github/renovate.json5: dockerfile の python を <3.14 に制限し再発防止 (upstream 対応待ち: tursodatabase/libsql-python#106) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 53 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR downgrades the backend Docker base image from Python 3.14 to 3.13 (with updated SHA256 digests), pins Renovate to block 3.14+ upgrades, adds a ChangesPython 3.13 downgrade, smoke-backend CI, and amd64 local dev tooling
Sequence Diagram(s)sequenceDiagram
participant GHA as GitHub Actions
participant DC as docker compose
participant API as api container
participant Health as /health
GHA->>GHA: Generate .env (RSA keypair, DB URL, secrets)
GHA->>DC: docker compose up -d --build api
DC->>API: Build python:3.13-slim → run alembic migrate → start uvicorn
loop Poll /health (up to N attempts)
GHA->>Health: GET http://localhost:8000/health
Health-->>GHA: 200 OK or connection refused
end
alt Health check failed
GHA->>DC: docker compose ps
GHA->>DC: docker compose logs api
DC-->>GHA: container state + stderr
GHA->>GHA: exit 1
end
GHA->>DC: docker compose down -v
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
test-backend(pytest) は標準 SQLite で動き本番イメージの起動経路
(libsql ネイティブ / alembic / uvicorn 起動)を検証しないため、Python 3.14
bump 時の起動 segfault を CI ですり抜けていた。実イメージ build → 実 libSQL
起動 → /health で起動成功を検証する smoke-backend ジョブを追加する。
- .github/workflows/ci.yml: smoke-backend ジョブ追加(amd64 ランナー)
- CLAUDE.md / rules/backend/{test,database}.md: ネイティブ・コンテナ起動は
smoke-backend で検証する方針を明文化(旧「検証されない」記述を更新)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In @.claude/rules/backend/test.md:
- Around line 30-33: There is conflicting guidance in this test documentation
file. The new section about pytest coverage clarifies that make test-backend
does not exercise Alembic migrations, libsql native driver, or container startup
paths (those are validated by the smoke-backend CI job instead). However, the
trigger list earlier in the document still instructs contributors to verify
migrations using make test-backend. Reconcile these sections by either removing
the make test-backend instruction from the migration verification checks in the
trigger list, or clarifying which specific checks use make test-backend versus
smoke-backend, so contributors follow consistent and non-contradictory guidance.
In @.github/workflows/ci.yml:
- Around line 302-303: The Checkout step in the GitHub Actions workflow is
persisting GitHub token credentials by default, which creates unnecessary
security risk since this job does not need to push back to the repository. Add
the persist-credentials option set to false in the actions/checkout step to
disable credential persistence and reduce the attack surface in accordance with
security guidelines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c5299bee-63e0-443b-901c-bd43252971b6
📒 Files selected for processing (8)
.claude/CLAUDE.md.claude/rules/backend/database.md.claude/rules/backend/test.md.github/renovate.json5.github/workflows/ci.ymlMakefilebackend/Dockerfiledocker-compose.amd64.yml
- ci.yml: smoke-backend の checkout に persist-credentials: false を付与 (push しないジョブのため認証情報を保持しない / codegen-drift と同方針) - rules/backend/test.md: マイグレーション追加トリガーの「make test-backend で確認」を smoke-backend / database.md 手順に整合(pytest は migration を通らない旨と矛盾しないよう修正) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
概要
devforge-apiがSegmentation fault(exit 139 / SIGSEGV)で起動ループする不具合の修正と、その再発防止一式です。根本原因
Renovate の
chore(deps): update python docker tag to v3.14で backend のベースイメージがpython:3.13-slim→python:3.14-slimに上がり、sqlalchemy-libsqlが引くlibsql-experimental(ネイティブ拡張)が Python 3.14 未対応で、起動時の alembic マイグレーション(app/db/bootstrap.py)で native crash していた。faulthandlerの C スタックがlibsql_experimentalの.soを指すことを確認済み。upstream / arch 検証
libsql-experimentalは 0.0.55 が最新で 3.14 対応版は未リリース(wheel は cp312 まで)。tursodatabase/libsql-experimental-python#106。変更内容
1. 修正(hotfix)
backend/Dockerfilepython:3.13-slim(元の SHA pin)へ戻す.github/renovate.json5dockerfileのpythonをallowedVersions: "<3.14"に制限(3.13.x patch・digest は維持し 3.14 bump のみ抑止)2. 再発防止(CI スモークテスト)
.github/workflows/ci.ymlsmoke-backendジョブ追加。本番イメージ build → 実 libSQL 起動 →/health(DB 接続検証)が 200 を返すことを確認。pytest が通らない「ビルドは成功するが起動時に native が segfault する」種の不具合を検知する3. 本番 arch 再現用ツール
docker-compose.amd64.yml/make dev-amd64(-build)4. ドキュメント
CLAUDE.md/rules/backend/{test,database}.mdmake test-backendでは検証されない」記述を更新)なぜ CI が green のまま本番が落ちたか
test-backendはuv python install 3.13+ 標準 SQLite(create_all)で動き、3.14 も libsql ネイティブ経路も一度も実行していなかった。本 PR のsmoke-backendはこの穴を塞ぐ(本 PR の CI でも自己検証される)。フォローアップ
upstream #106 が解決し
libsql-experimentalが 3.14 対応版を出したら、renovate.json5の<3.14制限を外して Python を上げ直す。🤖 Generated with Claude Code
Summary by CodeRabbit