Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

fab add may not be idempotent #294

Open
mtarng opened this issue Mar 30, 2020 · 1 comment
Open

fab add may not be idempotent #294

mtarng opened this issue Mar 30, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@mtarng
Copy link
Contributor

mtarng commented Mar 30, 2020

Describe the bug:
When calling fab add it excludes type: component at the top level of the component.yaml.
Subsequently, if you run the same command again, type:component will be added as, I suspect, it's being added to the object when loading from the component.yaml file.

To Reproduce:

  • Run fab add someservice --path ./someservice --method local --type component
  • cat component.yaml:
    name: somepath
    subcomponents:
    - name: someservice
      type: component
      method: local
      path: ./someservice
    
  • rerun fab add someservice --path ./someservice --method local --type component
  • cat component.yaml:
    name: somepath
    type: component
    subcomponents:
    - name: someservice
      type: component
      method: local
      path: ./someservice
    

notice type: component has been added at the top level.
Expected behavior:
type: component should probably be added on the first run.

Screenshots:

Additional context:

Desktop (please complete the following information):

  • OS:
    macOS
    Additional context
@andrewDoing
Copy link
Collaborator

I reproduced this bug on Windows.
The bug occurs within the function LoadComponent() in component.go

1st run: the error os.PathError is returned from UnmarshalComponent("yaml", ...)
loadedComponents and the error message "Error loading component in path ./" are returned.

2nd run: There is no error, as component.yaml now exists in the current directory. Moving forward, the function applyDefaultsAndMigrations() is called, adding the ComponentType of "component".

Potential Solution: Handle the specific error of os.PathError, adding the ComponentType of "component" in this case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants