-
Notifications
You must be signed in to change notification settings - Fork 156
Open
Labels
bugSomething isn't workingSomething isn't workinggoPull requests that update go codePull requests that update go codegood first issueGood for newcomersGood for newcomers
Description
Summary
The isRemoteWorkload function in pkg/workloads/statuses/file_status.go uses string matching instead of proper JSON parsing to detect if a workload is remote.
Current Behavior
// Check if the JSON contains "remote_url" field
return strings.Contains(string(data), `"remote_url"`), nilThis approach could incorrectly identify non-remote workloads as remote if the JSON happens to contain "remote_url" as part of a string value (not a field name).
Example of false positive:
{"description": "Set \"remote_url\" in config to enable remote mode"}Expected Behavior
Use proper JSON parsing to check if the remote_url field is set:
var config struct {
RemoteURL string `json:"remote_url"`
}
decoder := json.NewDecoder(reader)
if err := decoder.Decode(&config); err != nil {
return false, err
}
return config.RemoteURL != "", nilLocation
- File:
pkg/workloads/statuses/file_status.go - Function:
isRemoteWorkload(around line 79-104)
Additional Context
The function already has a TODO comment acknowledging this is a temporary solution:
// TODO: This is a temporary solution to check if a workload is remote
// because of the import cycle between this package and the runconfig package.The proposed fix would resolve this TODO while also fixing the edge case.
Acceptance Criteria
- Replace
strings.Containswith proper JSON decoding - Add unit test for the edge case (JSON containing "remote_url" in a string value)
- Ensure existing tests still pass
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggoPull requests that update go codePull requests that update go codegood first issueGood for newcomersGood for newcomers