amtrack / force-dev-tool

[DEPRECATED] Command line tool supporting the Force.com development lifecycle
MIT License
108 stars 37 forks source link

Error in changeset when the component is null #251

Open dabdemon opened 4 years ago

dabdemon commented 4 years ago

When a metadata is not supported, the getComponent() method returns null, but the code keeps running. While evaluating the component.type and component.name in the manifest.prototype.add method, an error is throw and the process fails.

To fix this we need to handle nulls appropriately, since new metadata may be supported yet.

amtrack commented 4 years ago

@dabdemon Thanks for reporting and sorry for the delay! As you described this already pretty well, could you please create a PR for this?

amtrack commented 4 years ago

@dabdemon Thank you for bringing up this topic and your PR #264! I now see your point and agree with you that MetadataFile.prototype.getComponent() can return null and in this case Manifest.prototype.add() currently fails trying to access the type and fullName property of the component. That's not good and I think we should act on MetadataFile.prototype.getComponent() if it returns null.

I can think of two ways to solve this, maybe there are more:

  1. continue returning null in MetadataFile.prototype.getComponent()
  2. throw an Error in MetadataFile.prototype.getComponent()

Then, we can check for null or catch the error and decide whether to exit with an error or print a warning like skipped src/foo/bar.baz of unknown metadata type depending on the situation.

I don't want to hide cases like that even more by silently ignoring Manifest.prototype.add(null) What do you think?