Description
When --file is passed to func invoke, the file contents are read from disk twice:
- In
newInvokeConfig() (line 280-286) — reads file into cfg.Data
- In
runInvoke() (line 201-207) — reads the same file again into m.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
Description
When
--fileis passed tofunc invoke, the file contents are read from disk twice:newInvokeConfig()(line 280-286) — reads file intocfg.DatarunInvoke()(line 201-207) — reads the same file again intom.DataThe second read is redundant because
m.Datais already initialized fromcfg.Dataat line 195, which already contains the file contents from the first read. The second read at line 206 just overwritesm.Datawith identical content.Impact
--file)Proposed Fix
Remove the second
os.ReadFileblock inrunInvoke()(lines 200-207). The file is already read intocfg.Dataduring config creation./kind cleanup