Skip to content

cmd: invoke reads --file data from disk twice (redundant I/O) #3846

Closed as not planned

Description

@Elvand-Lie

Description

When --file is passed to func invoke, the file contents are read from disk twice:

  1. In newInvokeConfig() (line 280-286) — reads file into cfg.Data
  2. 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

Activity

  1. gauron99 commented on May 26, 2026

    @gauron99
    Contributor

    The second read in runInvoke() is not redundant — it's the only one that runs after --confirm prompts may have changed cfg.File. The first read in newInvokeConfig() is the one that's likely unnecessary. I left a more detailed explanation on the PR (#3847).

  2. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no
    activity. It will automatically close after 30 more days of
    inactivity. Reopen the issue with /reopen. Mark the issue as
    fresh by adding the comment /remove-lifecycle stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions