You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a bundle and used newlines in some description fields. When the bundle.json was created, the newlines were preserved instead of converted to \n. This caused the bundle.json to not be valid json.
To Reproduce
porter create
Edit the porter.yaml and make the description multi-line
name: porter-hellodescription: |- I am a great bundle So great it takes two lines to describe me
porter build
Look at the .cnab/bundle.json and note that there are newlines in the description field
Expected behavior
We should validate the generated bundle.json before building the invocation image. This should have failed porter build but it didn't.
The generated bundle.json should change newlines to \n characters when writing the bundle.json. I would have assumed that the json marshal command would handle that for us but I guess it doesn't. So we should fixup any strings we set to do the conversion ourselves.
Porter Command and Output
Here is the misbehaving bundle.json
{"custom":{"sh.porter":{"manifest":"IyBUaGlzIGlzIHRoZSBjb25maWd1cmF0aW9uIGZvciBQb3J0ZXIKIyBZb3UgbXVzdCBkZWZpbmUgc3RlcHMgZm9yIGVhY2ggYWN0aW9uLCBidXQgdGhlIHJlc3QgaXMgb3B0aW9uYWwKIyBTZWUgaHR0cHM6Ly9wb3J0ZXIuc2gvYXV0aG9yLWJ1bmRsZXMgZm9yIGRvY3VtZW50YXRpb24gb24gaG93IHRvIGNvbmZpZ3VyZSB5b3VyIGJ1bmRsZQojIFVuY29tbWVudCBvdXQgdGhlIHNlY3Rpb25zIGJlbG93IHRvIHRha2UgZnVsbCBhZHZhbnRhZ2Ugb2Ygd2hhdCBQb3J0ZXIgY2FuIGRvIQoKbmFtZTogcG9ydGVyLWhlbGxvCnZlcnNpb246IDAuMS4wCmRlc2NyaXB0aW9uOiB8LQogIEFuIGV4YW1wbGUgUG9ydGVyIGNvbmZpZ3VyYXRpb24KICBXaXRoIGxvdHMgb2YgdGV4dAojIFRPRE86IHVwZGF0ZSB0aGUgcmVnaXN0cnkgdG8geW91ciBvd24sIGUuZy4gbXlyZWdpc3RyeQpyZWdpc3RyeTogZ2V0cG9ydGVyCgojIElmIHlvdSB3YW50IHRvIGN1c3RvbWl6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c2gvYXV0aG9yLWJ1bmRsZXMvI3BhcmFtZXRlcnMKI3BhcmFtZXRlcnM6CiMgIC0gbmFtZTogbXlzcWxfdXNlcgojICAgIHR5cGU6IHN0cmluZwojICAgIGRlZmF1bHQ6IHdvcmRwcmVzcwo=","manifestDigest":"bef91602c0af93df9c50e2c2473a9a054d71e3bc796e6e7c6cbd0b40e84add26","mixins":{"exec":{}}},"sh.porter.file-parameters":{}},"definitions":{"porter-debug-parameter":{"$comment":"porter-internal","$id":"https://porter.sh/generated-bundle/#porter-debug","default":false,"description":"Print debug information from Porter when executing the bundle","type":"boolean"}},"description":"An example Porter configuration
With lots of text","invocationImages":[{"image":"getporter/porter-hello-installer:v0.1.0","imageType":"docker"}],"name":"porter-hello","parameters":{"porter-debug":{"definition":"porter-debug-parameter","description":"Print debug information from Porter when executing the bundle","destination":{"env":"PORTER_DEBUG"}}},"requiredExtensions":["sh.porter.file-parameters"],"schemaVersion":"v1.0.0","version":"0.1.0"}
Version
v0.33.0
The text was updated successfully, but these errors were encountered:
I wanted to first try to build Porter with the cnab-go version in the following staged PR from Carolyn: cnabio/cnab-go#247
Sure enough, with that version (which uses a different canonical json library), we get the fix for free (\n chars substituted in where applicable) when marshal-ing the bundle. No extra code need be added to Porter! 🎉
Therefore, I propose we just sit on this and wait for it to be closed when Porter integrates the changes in the aforementioned PR.
Describe the bug
I created a bundle and used newlines in some description fields. When the bundle.json was created, the newlines were preserved instead of converted to \n. This caused the bundle.json to not be valid json.
To Reproduce
Look at the .cnab/bundle.json and note that there are newlines in the description field
Expected behavior
Porter Command and Output
Here is the misbehaving bundle.json
{"custom":{"sh.porter":{"manifest":"IyBUaGlzIGlzIHRoZSBjb25maWd1cmF0aW9uIGZvciBQb3J0ZXIKIyBZb3UgbXVzdCBkZWZpbmUgc3RlcHMgZm9yIGVhY2ggYWN0aW9uLCBidXQgdGhlIHJlc3QgaXMgb3B0aW9uYWwKIyBTZWUgaHR0cHM6Ly9wb3J0ZXIuc2gvYXV0a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bnN0YWxsIEhlbGxvIFdvcmxkIgogICAgICBjb21tYW5kOiAuL2hlbHBlcnMuc2gKICAgICAgYXJndW1lbnRzOgogICAgICAgIC0gdW5pbnN0YWxsCgojIEJlbG93IGlzIGFuIGV4YW1wbGUgb2YgaG93IHRvIGRlZmluZSBjcmVkZW50aWFscwojIFNlZSBodHRwczovL3BvcnRlci5zaC9hdXRob3ItYnVuZGxlcy8jY3JlZGVudGlhbHMKI2NyZWRlbnRpYWxzOgojICAtIG5hbWU6IGt1YmVjb25maWcKIyAgICBwYXRoOiAvcm9vdC8ua3ViZS9jb25maWcKIyAgLSBuYW1lOiB1c2VybmFtZQojICAgIGVudjogVVNFUk5BTUUKCiMgQmVsb3cgaXMgYW4gZXhhbXBsZSBvZiBob3cgdG8gZGVmaW5lIHBhcmFtZXRlcnMKIyBTZWUgaHR0cHM6Ly9wb3J0ZXIuc2gvYXV0aG9yLWJ1bmRsZXMvI3BhcmFtZXRlcnMKI3BhcmFtZXRlcnM6CiMgIC0gbmFtZTogbXlzcWxfdXNlcgojICAgIHR5cGU6IHN0cmluZwojICAgIGRlZmF1bHQ6IHdvcmRwcmVzcwo=","manifestDigest":"bef91602c0af93df9c50e2c2473a9a054d71e3bc796e6e7c6cbd0b40e84add26","mixins":{"exec":{}}},"sh.porter.file-parameters":{}},"definitions":{"porter-debug-parameter":{"$comment":"porter-internal","$id":"https://porter.sh/generated-bundle/#porter-debug","default":false,"description":"Print debug information from Porter when executing the bundle","type":"boolean"}},"description":"An example Porter configuration With lots of text","invocationImages":[{"image":"getporter/porter-hello-installer:v0.1.0","imageType":"docker"}],"name":"porter-hello","parameters":{"porter-debug":{"definition":"porter-debug-parameter","description":"Print debug information from Porter when executing the bundle","destination":{"env":"PORTER_DEBUG"}}},"requiredExtensions":["sh.porter.file-parameters"],"schemaVersion":"v1.0.0","version":"0.1.0"}
Version
v0.33.0
The text was updated successfully, but these errors were encountered: