bigquery-derive: reject ambiguous and duplicate #[bigquery(...)] attributes at compile time
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start with src/bigquery-derive/src/lib.rs, especially get_field_name, derive_from_row_impl, and derive_from_sql_impl, then read the proc-macro guidance in doc/contributor/howto-guide-handwritten-client-api.md. Add unit tests there for duplicate resolved names, duplicate rename options across and within attributes, and unsupported container attributes; done when each case produces a spanned compile-time error.
索引モデルが issue の本文から書いたものです。
説明
Summary
google-cloud-bigquery-derive (#[derive(FromRow)] and #[derive(FromSql)]) silently accepts ambiguous and invalid #[bigquery(...)] attribute configurations instead of rejecting them with compile-time errors.
Because rejecting input that previously compiled is a breaking change to accepted macro input under the proc-macro compatibility policy (src/bigquery-derive/src/lib.rs), fixing these validation gaps before google-cloud-bigquery 1.0.0 is released (#7424) avoids requiring a major bump of google-cloud-bigquery later.
Problem Details
Per doc/contributor/howto-guide-handwritten-client-api.md:
Ambiguous input (for example, two fields mapping to the same property name after flattening) is an error, never resolved silently.
Currently in src/bigquery-derive/src/lib.rs:
- Duplicate target column /
STRUCTfield names compile silently and exhibit transport-dependent runtime behavior:derive_from_row_implandderive_from_sql_implresolve each named field's column/field name independently without checking for duplicates across the struct.- For example:
(or two fields both marked#[derive(FromRow)] struct AmbiguousRow { col: Option<String>, #[bigquery(rename = "col")] other: Option<String>, }#[bigquery(rename = "same")], orr#typecolliding with#[bigquery(rename = "type")]). - At runtime,
FromRowemits tworow.take("col")?calls:- On JSON-backed rows (
RowInner::Jsoninsrc/bigquery/src/query/row.rs), the firsttakereplaces cell"col"withSqlValueInner::Null, soothersilently receivesNone(or fails withConvertError::NotNullfor non-optional types). - On Arrow-backed rows (
RowInner::Arrowinsrc/bigquery/src/query/row.rs),takereads from theRecordBatchwithout mutating it, so bothcolandotherreceive"col"'s value.
- On JSON-backed rows (
FromSql(SqlValue::take) has the same discrepancy betweenSqlValueInner::Struct(replaces slot withNull) andSqlValueInner::Arrow(reads without mutating).
- Multiple
#[bigquery(...)]attributes on the same field short-circuit after the firstrename:- In
get_field_name(src/bigquery-derive/src/lib.rs),if let Some(name) = renamed { return Ok(name); }returns inside thefor attr in &field.attrsloop. - A second
#[bigquery(rename = "...")]on the same field is silently ignored instead of reporting a duplicaterenameerror, and a subsequent invalid attribute (e.g.,#[bigquery(rename = "a")] #[bigquery(typo = "b")]) is never parsed at all.
- In
- Duplicate
renameoptions inside a single attribute overwrite silently:#[bigquery(rename = "a", rename = "b")]overwritesrenamed = Some(lit.value())without checking ifrenamewas already specified, silently using"b".
- Container-level
#[bigquery(...)]attributes on structs are silently ignored:- Neither
derive_from_row_implnorderive_from_sql_implinspectsinput.attrs, so unsupported container attributes such as#[bigquery(rename_all = "camelCase")]on a struct compile without error and have no effect.
- Neither
Expected Behavior
- Reject structs where two or more fields resolve to the same BigQuery column /
STRUCTfield name with a spannedsyn::Error. - Inspect all
#[bigquery(...)]attributes on every field and reject duplicaterenameoptions (whether in one#[bigquery(rename = "a", rename = "b")]list or across multiple#[bigquery(...)]attributes on the same field). - Reject
#[bigquery(...)]attributes placed on the container (struct/enum/union) itself until/unless container options are explicitly supported. - Add unit tests in
src/bigquery-derive/src/lib.rscovering each error case, and take a breaking version bump ongoogle-cloud-bigquery-deriveif needed per the compatibility policy.
- 主要言語
- Rust
- スター
- 972
- フォーク
- 163
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 176
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-rust のほかの issue
-
type: process
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-rust#7466 ·
メンテナーはふだん 1 日以内に返信
-
type: process
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
googleapis/google-cloud-rust#7465 ·
メンテナーはふだん 1 日以内に返信
-
api: storage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
googleapis/google-cloud-rust#7344 ·
メンテナーはふだん 1 日以内に返信
-
BytesValue in Any rejects unpadded and URL-safe base64対応中かも @akasakariko が 19 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
googleapis/google-cloud-rust#6714 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
type: bug
難易度 2/5 半日 初心者へのやさしさ 75/100
googleapis/google-cloud-rust#6710 ·
メンテナーはふだん 1 日以内に返信
googleapis/google-cloud-rust の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
obi1kenobi/cargo-semver-checks#1814 ·
メンテナーはふだん 1 日以内に返信
-
community differential help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
hffgzktbcc-blip/ounce-core#489 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pbakaus/impeccable#1560 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
pact-foundation/pact-plugins#125 ·