Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

func.yaml schema generator truncates fractional `minimum` values (e.g. 0.01 -> 0)

Aperta
#4,066 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Elvand-Lie ci sta già lavorando.

Dal 26/9/2026.

  • #4067 di @Elvand-Lie — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start with schema/generator/main.go, then inspect the jsonschema dependency's reflect.go handling of minimum and maximum values. Compare the generated schema/func_yaml-schema.json with ValidateScale for fractional minima. Done means the published schema preserves fractional minimum values and agrees with runtime validation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The func.yaml JSON schema is generated with github.com/alecthomas/jsonschema. Its number-keyword handling stores minimum/maximum as int (Type.Minimum int, reflect.go:60) and parses the tag value with strconv.Atoi — for both the jsonschema tag (numbericKeywords, reflect.go:614) and the jsonschema_extras tag (extraKeywords). A fractional minimum such as 0.01 fails to parse, the error is discarded, and the emitted schema gets minimum: 0.

As a result, schema-based validation is looser than the runtime ValidateScale. For example scale.kpa.target requires >= 0.01 at runtime, but the generated schema only enforces > 0 (via an exclusiveMinimum: true workaround), so a value like 0.001 passes the published schema/func_yaml-schema.json while ValidateScale rejects it at deploy time.

This is a pre-existing, generator-wide limitation affecting any fractional minimum (not specific to the scale fields): the library simply cannot express a non-integer minimum.

Possible fixes
  • Post-process the generated schema in schema/generator/main.go to set fractional minima after reflection (targeted, but per-field).
  • Switch to a jsonschema library / tag path that supports float minima, then regenerate schema/func_yaml-schema.json so schema validation matches ValidateScale.
Context

Surfaced by the Copilot review of #4063:
https://github.com/knative/func/pull/4063#discussion_r4098380996

Lingua principale
Go
Stelle
366
Fork
226
Merge medio
2g 17h
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di knative/func

Tutte le issue di knative/func

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.