`migration-risk` text output prints `app.None` for graph-level findings
評価
- 難易度
- 1/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
調査の方向性
ヘッダー行は cli/orm_lens/cli.py のテキスト出力で、313〜317行目付近の f"{f.operation} {f.app}.{f.model}" によって作られています。グラフレベルの検出結果ではアプリ名だけが表示されるように、f.model が設定されている場合にのみモデル部分が表示されるようにしてください。cli/tests/test_cli_subcommands_smoke.py にケースを追加し、2つの leaf を持つ再現ケースに対して migration-risk を実行して、None なしで (migration graph) shop と表示されることを確認してください。通常の AddField の検出結果は引き続き app.model.field を表示する必要があります。そのテスト、pytest、ruff、mypy がすべて通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Source: pretix sendmail, weblate trans (seen while checking the conflicting_migration_leaves reports from #246 and #247)
What happens
The text output of migration-risk prints f"{f.operation} {f.app}.{f.model}". Graph-level findings have no model: conflicting_migration_leaves and alembic_multiple_heads both set model=None. So the header line reads (migration graph) shop.None.
--format sarif and --format github are fine, only the text format has it. Same family as #207.
Repro
shop/models.py
from django.db import models
class Item(models.Model):
name = models.CharField(max_length=100)
price = models.IntegerField(default=0)
sku = models.CharField(max_length=20, default="")
shop/migrations/: 0001_initial.py creates Item(id, name), then two branches that both depend on it:
# 0002_item_price.py
class Migration(migrations.Migration):
dependencies = [("shop", "0001_initial")]
operations = [migrations.AddField(model_name="item", name="price", field=models.IntegerField(default=0))]
# 0002_item_sku.py
class Migration(migrations.Migration):
dependencies = [("shop", "0001_initial")]
operations = [migrations.AddField(model_name="item", name="sku", field=models.CharField(max_length=20, default=""))]
This is a real conflict, so the finding itself is right. Only the header line is off:
$ orm-lens migration-risk
shop/migrations/0002_item_price.py:1 [critical/high] (migration graph) shop.None
rule: conflicting_migration_leaves
risk: App 'shop' has 2 leaf migrations (0002_item_price, 0002_item_sku). ...
shop/migrations/0002_item_sku.py:1 [critical/high] (migration graph) shop.None
rule: conflicting_migration_leaves
...
Expected: (migration graph) shop.
Where
cli/orm_lens/cli.py, lines 313–317: the header line of the text format.cli/orm_lens/migrations_parser.py, line 1522, andcli/orm_lens/alembic_risk.py, line 467: the two places that create a finding withmodel=None(for reference, no change needed there).
Suggested fix
Build the target from the parts that are set: f.app, then .{f.model} only when f.model is set, then .{f.field} as now. A small helper next to the print keeps it readable.
How to test
cli/tests/test_cli_subcommands_smoke.py: runmigration-riskon the repro tree, check the output has(migration graph) shopand noNone.- A normal finding (
AddFieldNOT NULL without default) still printsapp.model.field. cd cli && python -m pytest -q,ruffandmypypass.
Difficulty: good first issue, one line and a test.
- 主要言語
- Python
- スター
- 84
- フォーク
- 13
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FROWNINGdev/django-orm-lens のほかの issue
-
suggest-indexes proposes composite indexes that include the primary key or a unique field対応中かも @bfs2021 が今日担当しました。 オープンbug good first issue python
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
FROWNINGdev/django-orm-lens#269 ·
-
Finish the Chinese rule reference — DOL001–DOL007再び着手できるかも @harbinresearcher が 64 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンdocumentation good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
FROWNINGdev/django-orm-lens#81 · コメント 2 件 ·
-
Fields inherited from Django's `AbstractBaseUser` / `PermissionsMixin` / `AbstractUser` are missingオープンbug good first issue python
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
FROWNINGdev/django-orm-lens#267 ·
-
bug good first issue python
難易度 3/5 半日 初心者へのやさしさ 78/100
FROWNINGdev/django-orm-lens#266 ·
-
enhancement help wanted python
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
FROWNINGdev/django-orm-lens#254 ·
FROWNINGdev/django-orm-lens の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gorakhargosh/watchdog#1462 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
openwisp/openwisp-monitoring#889 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
OpenFreeEnergy/Lomap#180 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
roman-corgi/corgisim#327 ·
メンテナーはふだん 2 日以内に返信
-
agent:WSL bug code-review linux pri:medium sev:low tooling
難易度 2/5 半日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信