Skip to content

fix(agent/file): NewIFileService should return IFileService, not FileService#12648

Open
eddieran wants to merge 1 commit into1Panel-dev:dev-v2from
eddieran:fix/agent-newifileservice-return-type
Open

fix(agent/file): NewIFileService should return IFileService, not FileService#12648
eddieran wants to merge 1 commit into1Panel-dev:dev-v2from
eddieran:fix/agent-newifileservice-return-type

Conversation

@eddieran
Copy link
Copy Markdown

@eddieran eddieran commented May 1, 2026

Summary

agent/app/service/file.go:94 declares the constructor with a bare struct return type:

func NewIFileService() FileService {
    return &FileService{}
}

But the body returns a pointer (&FileService{}), and the function name (NewIFileService) suggests the caller should receive the interface (IFileService).

Repro

`go build ./...` on the `agent` module currently fails:

$ go build ./...
# github.com/1Panel-dev/1Panel/agent/app/service
app/service/file.go:95:9: cannot use &FileService{} (value of type *FileService) as FileService value in return statement
app/service/website_proxy.go:276:36: cannot call pointer method GetFileList on FileService

The second error is a downstream consequence: website_proxy.go:276 calls NewIFileService().GetFileList(...), which fails because GetFileList has a pointer receiver but NewIFileService is declared to return a value.

Fix

One-line change: declare the return type as the interface.

-func NewIFileService() FileService {
+func NewIFileService() IFileService {
        return &FileService{}
 }

*FileService implements every method on IFileService (verified with go vet ./...).

Verification

  • go build ./... — clean
  • go vet ./... — clean

Notes

This regression appears to have been introduced in commit `e57dc12` (#12529 area). No other call sites of `NewIFileService` reference the concrete type; switching to the interface is fully source-compatible with existing consumers.

`NewIFileService` returns the bare struct type `FileService`, but its
body returns a pointer (`&FileService{}`), and the function name suggests
it should return the interface (`IFileService`). The current signature
breaks `go build ./...` on the `agent` module:

    app/service/file.go:95:9: cannot use &FileService{} (value of type
        *FileService) as FileService value in return statement
    app/service/website_proxy.go:276:36: cannot call pointer method
        GetFileList on FileService

Both errors resolve when the constructor returns the interface, since
`*FileService` implements every method on `IFileService` (verified with
`go vet ./...`).

After this change, `go build ./...` and `go vet ./...` are clean on the
`agent` module.
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 1, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 1, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign wanghe-fit2cloud for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

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