Integer default values on `Float` input fields generate code that does not compile (Java and Kotlin)
I maintainer di solito rispondono entro 1 giorno
@0z5a ci sta già lavorando.
Dal 17/11/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, build-system
Direzione di ricerca
Start by reading the Java and Kotlin code generation paths that emit defaults for GraphQL Float input fields, then inspect the tests covering generated input types and builders. Reproduce with the schema in the issue and compile generated code for Java, Kotlin, and Kotlin2. Done when integer defaults such as 1 and [1, 2.5] generate valid floating point values across the reported cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
GraphQL accepts an integer literal as the default value of a Float input field (ratio: Float = 1). Codegen copies the literal as is, so the generated field is a Double/Double? initialized with an Int. Java rejects this for nullable fields and lists, and Kotlin rejects it for every case (nullable, non-null and list). Issue #787 and PR #803 fixed Float! = 0.0 in Kotlin; the integer-literal form is still broken in both generators.
To reproduce
input ExampleInput {
ratio: Float = 1
minRatio: Float! = 0
ratios: [Float] = [1, 2.5]
}
Generate Java types (default config) and compile them:
error: incompatible types: int cannot be converted to java.lang.Double
error: incompatible types: inference variable T has incompatible bounds
(the same two errors are reported again for the builder). minRatio compiles in Java only because double minRatio = 0 uses a primitive.
Kotlin (language = KOTLIN):
error: initializer type mismatch: expected 'Double?', actual 'Int'.
error: initializer type mismatch: expected 'Double', actual 'Int'.
error: initializer type mismatch: expected 'List<Double?>?', actual 'List<Number & Comparable<*>>'.
Kotlin2 (generateKotlinNullableClasses = true):
error: argument type mismatch: actual type is 'Int', but 'Double?' was expected.
error: argument type mismatch: actual type is 'Int', but 'Double' was expected.
error: argument type mismatch: actual type is 'List<Number & Comparable<*>>', but 'List<Double?>?' was expected.
Expected behavior
The schema is valid. The GraphQL spec (Float, input coercion) accepts integer input values and coerces them to Float by adding an empty fractional part, so 1 should become 1.0. Expected output: Double ratio = 1.0;, Arrays.asList(1.0, 2.5) in Java, and ratio: Double? = 1.0, listOf(1.0, 2.5) in Kotlin.
Integer defaults on Float input fields are common in hand-written schemas, for example quantity: Float = 1 or fee: Float = 0.
Environment
dgs-codegen main (6aa5bdaa), macOS arm64. Reproduced with the unit tests in the linked PR.
This issue was drafted with Claude Code (claude-opus-5-5); the results above are from the runs described.
- Lingua principale
- Kotlin
- Stelle
- 220
- Fork
- 123
- Merge medio
- 1g 6h
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Netflix/dgs-codegen
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
Netflix/dgs-codegen#1002 ·
I maintainer di solito rispondono entro 1 giorno
-
Object literal default value on a custom scalar fails with NoSuchElementExceptionForse già presa @nboisnea l’ha presa 49 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Netflix/dgs-codegen#982 ·
I maintainer di solito rispondono entro 1 giorno
-
HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).Forse già presa @jiholee17 l’ha presa 73 giorni fa. Apertaenhancement
Netflix/dgs-codegen#954 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Support Immutable java Data TypesForse di nuovo libera @jiholee17 l’ha presa 184 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Netflix/dgs-codegen#944 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Java codegen: generate sealed interface for GraphQL interfaces/unions and record for implementing typesForse di nuovo libera @jiholee17 l’ha presa 233 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Netflix/dgs-codegen#923 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Netflix/dgs-codegen
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
DojoCodingLabs/hermit#23 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
signalapp/Signal-Android#15148 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
PranshulGG/WeatherMaster#1266 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno