Skip to content

bug: IsParent doesn't handle the case where paths are empty properly #1116

@HarikrishnanBalagopal

Description

@HarikrishnanBalagopal

Bug

Overview

func IsParent(child, parent string) bool {

When path is relative it joins with the current working.
In WASM the current working directory is / and we hit this if condition

move2kube/common/utils.go

Lines 1088 to 1090 in e88cece

if parent == "/" {
return true
}

so it returns true.

And because IsParent returns true, we try to make a path relative to an empty string '' and hit this error

rel, err := filepath.Rel(e.GetEnvironmentOutput(), path)
if err != nil {
logrus.Errorf("Unable to make path (%s) relative to output (%s) : %s ", path, e.GetEnvironmentOutput(), err)

Fix

  • Make sure all the paths are absolute before giving to these functions. We should be using absolute paths everywhere.
  • Also add a if parent == "" || child == "" { return false; } in the IsParent function

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions