Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#4,066 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Elvand-Lie がすでに取り組んでいます。

2026年9月26日 から。

  • #4067 @Elvand-Lie による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Go
スター
365
フォーク
224
平均マージ
1日 13時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

knative/func のほかの issue

knative/func の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。