0.9.11-beta: SchemaIntegrityVerifier false positives on Schema/AllTablesInSchema grants + text column ::text default

オープン
#61 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp, postgresql
領域
databases

調査の方向性

Start at SchemaIntegrityVerifier and its InspectSchemaGrants entry point, using the documented dotnet DataProviderMigrate command and PostgreSQL queries to reproduce both false positives. Review scripts/migrate_schema.py for the current workaround. Done means Schema and AllTablesInSchema grants are recognised, text defaults compare consistently, and repeated migrations converge without integrity failures.

索引モデルが issue の本文から書いたものです。

説明

Repro

YAML schema with:

grants:
  - schema: public
    target: Schema
    privileges: [USAGE]
    roles: [app_user, app_admin]
  - schema: public
    target: AllTablesInSchema
    privileges: [SELECT, INSERT, UPDATE, DELETE]
    roles: [app_user, app_admin]

Run dotnet DataProviderMigrate --schema schema.yaml --output "<postgres-dsn>" --provider postgres.

Expected

Migration converges. SchemaIntegrityVerifier reports clean.

Actual

Migration completed successfully
SCHEMA INTEGRITY CHECK FAILED
grant Schema public: missing grant
grant AllTablesInSchema public: missing grant

Exit code 1. Re-running is non-converging — the verifier reports the same missing grants on every run.

Verification that the grants are actually applied

-- Schema USAGE: explicit grant present in nspacl
SELECT nspname, nspacl FROM pg_namespace WHERE nspname='public';
--  public | {... app_user=U/pg_database_owner, app_admin=U/pg_database_owner}

-- has_schema_privilege() returns true
SELECT has_schema_privilege('app_user',  'public', 'USAGE');  -- t
SELECT has_schema_privilege('app_admin', 'public', 'USAGE'); -- t

-- Table grants: every public table shows arwd in relacl for both roles
SELECT relname, relacl
  FROM pg_class
 WHERE relnamespace='public'::regnamespace AND relkind='r' LIMIT 1;
--  users | {... app_user=arwd/postgres, app_admin=arwd/postgres}

So the migrate step applies the grants correctly. The verifier's InspectSchemaGrants simply doesn't recognise the applied state.

Side issue (also new in 0.9.11): text column defaults

defaultValue: "'generating'" in YAML round-trips to 'generating'::text in information_schema.columns.column_default (Postgres normalises text literals). The verifier reports:

public.sites.status: default expected 'generating' but found 'generating'::text

Workaround: spell the YAML as defaultValue: "'generating'::text". The verifier should ideally strip the ::text cast (or apply the same normalisation to both sides) before comparing.

Environment

  • DataProviderMigrate 0.9.11-beta
  • Postgres 16 (Supabase docker stack)
  • Same YAML migrates cleanly under 0.9.10-beta (the verifier step appears to be new in 0.9.11).

Workaround we're shipping

Until this lands we invoke dotnet DataProviderMigrate via a Python wrapper that swallows exactly the two known false-positive lines after asserting Migration completed successfully is in stdout — see scripts/migrate_schema.py. Happy to delete the wrapper once the verifier is fixed.

主要言語
C#
スター
68
フォーク
4
平均マージ
50分
マージ済み PR(30日)
2

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Nimblesite/DataProvider のほかの issue

Nimblesite/DataProvider の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。