Skip to content

warn on extraneous keys used in func.yaml#3611

Merged
knative-prow[bot] merged 1 commit intoknative:mainfrom
gauron99:push-kxrnrqtrmwxs
Apr 16, 2026
Merged

warn on extraneous keys used in func.yaml#3611
knative-prow[bot] merged 1 commit intoknative:mainfrom
gauron99:push-kxrnrqtrmwxs

Conversation

@gauron99
Copy link
Copy Markdown
Contributor

@gauron99 gauron99 commented Apr 15, 2026

adding a warning for extraneous keys

❯ func run
Warning (unknown fields will be ignored):
 'func.yaml' is not valid:
  line 7: unknown field "junk"
  line 8: unknown field "builder"
  line 9: unknown field "tralala"

when we have the latest (migrated) spec present, we do a strict Unmarshal (which errors on extraneous keys) and we print a warning like above.
Note that Im adding the "once" because NewFunction is actually called few times throughout a lets say "func deploy" call.

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Apr 15, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow Bot added the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label Apr 15, 2026
@gauron99 gauron99 marked this pull request as ready for review April 15, 2026 17:37
@knative-prow knative-prow Bot added approved 🤖 PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. labels Apr 15, 2026
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos April 15, 2026 17:37
@knative-prow knative-prow Bot added the size/S 🤖 PR changes 10-29 lines, ignoring generated files. label Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.30%. Comparing base (76c33b2) to head (b2d0a34).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3611      +/-   ##
==========================================
+ Coverage   56.27%   56.30%   +0.03%     
==========================================
  Files         180      180              
  Lines       20522    20549      +27     
==========================================
+ Hits        11548    11571      +23     
- Misses       7773     7777       +4     
  Partials     1201     1201              
Flag Coverage Δ
e2e 36.22% <70.00%> (+0.02%) ⬆️
e2e go 32.86% <66.66%> (+0.01%) ⬆️
e2e node 28.62% <66.66%> (+0.03%) ⬆️
e2e python 33.23% <66.66%> (+0.01%) ⬆️
e2e quarkus 28.76% <66.66%> (+0.03%) ⬆️
e2e rust 28.18% <66.66%> (+0.03%) ⬆️
e2e springboot 26.65% <66.66%> (+0.03%) ⬆️
e2e typescript 28.73% <66.66%> (+<0.01%) ⬆️
e2e-config-ci 18.08% <66.66%> (+<0.01%) ⬆️
integration 17.51% <66.66%> (+0.04%) ⬆️
unit macos-14 43.35% <100.00%> (+0.05%) ⬆️
unit macos-latest 43.35% <100.00%> (+0.05%) ⬆️
unit ubuntu-24.04-arm 43.55% <100.00%> (+0.04%) ⬆️
unit ubuntu-latest 44.23% <100.00%> (+0.04%) ⬆️
unit windows-latest 43.38% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gauron99 gauron99 force-pushed the push-kxrnrqtrmwxs branch from ddf6369 to 466cbd5 Compare April 15, 2026 18:52
@gauron99 gauron99 requested review from lkingland and matejvasek and removed request for dsimansk and jrangelramos April 15, 2026 20:28
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just add a few test cases covering the new conditional logic. Thank you 😸 👍

@gauron99 gauron99 force-pushed the push-kxrnrqtrmwxs branch from 466cbd5 to df47c5f Compare April 16, 2026 08:38
@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. and removed size/S 🤖 PR changes 10-29 lines, ignoring generated files. labels Apr 16, 2026
@gauron99 gauron99 force-pushed the push-kxrnrqtrmwxs branch from df47c5f to 5a0d73b Compare April 16, 2026 09:17
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you for the tests.

I have just a minor nit => optional.

/approve
/lgtm
/hold for others

Comment on lines +26 to +35
if f.Root != "" {
if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil {
unknownFieldsOnce.Do(func() {
var strict Function
if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil {
fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr))
}
})
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use early return

Suggested change
if f.Root != "" {
if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil {
unknownFieldsOnce.Do(func() {
var strict Function
if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil {
fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr))
}
})
}
}
if f.Root == "" {
return f, nil
}
if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil {
unknownFieldsOnce.Do(func() {
var strict Function
if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil {
fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr))
}
})
}

@knative-prow knative-prow Bot added do-not-merge/hold 🤖 PR should not merge because someone has issued a /hold command. lgtm 🤖 PR is ready to be merged. labels Apr 16, 2026
Comment thread pkg/functions/function_migrations.go Outdated
// Migrate applies any necessary migrations, returning a new migrated
// version of the function. It is the caller's responsibility to
// .Write() the function to persist to disk.
// .Write() the function to persist to disk. Aditionaly it will warn on
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Aditionaly => Additionally

@gauron99 gauron99 force-pushed the push-kxrnrqtrmwxs branch from 5a0d73b to b2d0a34 Compare April 16, 2026 14:43
@knative-prow knative-prow Bot removed the lgtm 🤖 PR is ready to be merged. label Apr 16, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Apr 16, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, matejvasek, twoGiants

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [gauron99,matejvasek]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@matejvasek
Copy link
Copy Markdown
Contributor

/unhold

@knative-prow knative-prow Bot removed the do-not-merge/hold 🤖 PR should not merge because someone has issued a /hold command. label Apr 16, 2026
@knative-prow knative-prow Bot merged commit 1d63f7b into knative:main Apr 16, 2026
64 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants