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

未关闭
#61 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 分钟
30 天内合并 PR
2

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Nimblesite/DataProvider 的其他 Issue

查看 Nimblesite/DataProvider 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。