Object literal default value on a custom scalar fails with NoSuchElementException
メンテナーはふだん 1 日以内に返信
@nboisnea がすでに取り組んでいます。
2026年10月8日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Start with DataTypeGenerator.kt and GenerateKotlinCode.kt, in the default-value generators named in the issue; trace how ObjectValue is handled for scalar fields versus input types. Check the existing array-default generation and tests for Java and Kotlin, then add coverage for mapped and unmapped scalar defaults, including object literals nested in lists. Done means supported mapped cases generate the expected initializers and unsupported cases fail with the stated contextual message.
索引モデルが issue の本文から書いたものです。
説明
An input field whose type is a custom scalar cannot have an object literal as default value. This is valid GraphQL (graphql-java accepts it), and should work as long as the the scalar implementation's parseLiteral accepts ObjectValues, but generateJava fails with:
Execution failed for task ':generateJava'.
> Collection contains no element matching the predicate.
This happens for both Java and Kotlin, whether or not the scalar has a typeMapping and whatever it is mapped to. It also happens for object literals nested in a list default ([JSON] = [{}]).
Reproduction
Plugin version 8.7.0:
scalar JSON
type Query {
search(filter: FilterInput): String
}
input FilterInput {
metadata: JSON = {}
}
generateJava {
packageName = 'com.example'
typeMapping = ['JSON': 'java.util.Map<String, Object>']
}
Java:
Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
at com.netflix.graphql.dgs.codegen.generators.java.InputTypeGenerator.defaultCodeBlock(DataTypeGenerator.kt:946)
at com.netflix.graphql.dgs.codegen.generators.java.InputTypeGenerator.generateCode(DataTypeGenerator.kt:246)
...
Kotlin (language = 'kotlin'):
Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
at com.netflix.graphql.dgs.codegen.generators.shared.GenerateKotlinCodeKt.generateKotlinCode(GenerateKotlinCode.kt:155)
at com.netflix.graphql.dgs.codegen.generators.kotlin.KotlinInputTypeGenerator.generate(KotlinDataTypeGenerator.kt:124)
...
Cause
The ObjectValue branch of the default value generators (DataTypeGenerator.kt for Java, GenerateKotlinCode.kt for Kotlin) assumes the field type is an input type and looks up its definition with first { ... }. When the field type is a scalar, no input type matches.
Expected
- When the scalar is explicitly mapped to a
Map, generate a map initializer, the same wayArrayValuegenerates a list:- Java:
new HashMap<>()for{}, and a populated map for object literals with fields - Kotlin:
emptyMap()for{}, andmapOf("key" to value, ...)for object literals with fields
- Java:
- Otherwise, fail with an explicit message naming the input type and field, rather than
NoSuchElementException.
- 主要言語
- Kotlin
- スター
- 220
- フォーク
- 123
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Netflix/dgs-codegen のほかの issue
-
Integer default values on `Float` input fields generate code that does not compile (Java and Kotlin)対応中かも @0z5a が 8 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
Netflix/dgs-codegen#1015 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
Netflix/dgs-codegen#1002 ·
メンテナーはふだん 1 日以内に返信
-
HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).対応中かも @jiholee17 が 72 日前に担当しました。 オープンenhancement
Netflix/dgs-codegen#954 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Support Immutable java Data Types再び着手できるかも @jiholee17 が 183 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
Netflix/dgs-codegen#944 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Java codegen: generate sealed interface for GraphQL interfaces/unions and record for implementing types再び着手できるかも @jiholee17 が 233 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
Netflix/dgs-codegen#923 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Netflix/dgs-codegen の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
PranshulGG/WeatherMaster#1266 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsotto/sotto-authenticator#68 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 4 日以内に返信
-
mobile prio:low
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
digitalfabrik/entitlementcard#3324 ·
メンテナーはふだん 2 日以内に返信