cmd: invoke reads --file data from disk twice (redundant I/O)
@Elvand-Lie is already working on this.
Since Jun 2, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
When --file is passed to func invoke, the file contents are read from disk twice:
- In
newInvokeConfig()(line 280-286) — reads file intocfg.Data - In
runInvoke()(line 201-207) — reads the same file again intom.Data
The second read is redundant because m.Data is already initialized from cfg.Data at line 195, which already contains the file contents from the first read. The second read at line 206 just overwrites m.Data with identical content.
Impact
- Wasted I/O (file read twice for every invocation with
--file) - TOCTOU consistency risk: if the file changes between the two reads, the behavior would be unpredictable
Proposed Fix
Remove the second os.ReadFile block in runInvoke() (lines 200-207). The file is already read into cfg.Data during config creation.
/kind cleanup
- Dominant language
- Go
- Stars
- 365
- Forks
- 223
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 25
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from knative/func
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
lifecycle/stale
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
setServiceOptions: %f format produces invalid autoscaling annotation values with trailing zeros Openlifecycle/stale
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·