Orb example formatting gets mangled after publishing

I’m trying to provide example usage of an orb, but the example that ends up in the Orb repository is different to how I formatted it.

Original: https://github.com/adamu/slack-webhook-orb/blob/0.0.2/slack-webhook-orb.yml#L71-L82
Result: https://circleci.com/developer/orbs/orb/adamu/slack-webhook?version=0.0.2#usage-webhook-url

You can see that it’s converted the multi-line JSON string into a single line, full of newline escapes, which is completely unreadable, and changes the example from being a good example to a bad one.

The strange thing is, the same thing doesn’t seem to happen for a similar official orb.
Original: https://github.com/CircleCI-Public/slack-orb/blob/v4.0.1/src/examples/custom_notification.yml#L17-L31
Result: https://circleci.com/developer/orbs/orb/circleci/slack?version=4.0.1#usage-custom_notification

I inspected the circleci/slack orb source with circleci orb source circleci/slack@4.0.1 and tried a couple of things based on that:

  1. Indenting with 4 spaces instead of 2
  2. Using tabs inside the json instead of spaces

But no luck.

Does anybody have any ideas?


I just did a test of this, and it seems like the newlines were preserved. I basically just cloned your repo and deleted and changed a few fields.

Do you happen to be running under Windows? I’m curious if something there might be causing the issue with newlines.

What version of the CircleCI CLI are you using? You can find that with:

circleci version

Hi Adam, welcome to CircleCI Discuss!

First, I second @mike’s post. Let’s try running

circleci update

and republishing the orb before taking more drastic steps.

Taking a look at your orb, I can see that you are using the older orb format. If upgrading your local CircleCI CLI does not fix this, I recommend using the CircleCI Orb Developer Kit to jump start the transition to the new orb format: https://circleci.com/docs/2.0/orb-author/#orb-development-kit

The new format includes the “examples” folder, in which you explicitly define the examples that are shown on the developer hub. I initially had the feeling that the newline characters are being placed as a result of your examples being auto-generated, but for some reason this wasn’t the case for Mike’s fork of your repository. Perhaps when you explicitly define the examples, this circumvents the issue that causes the newline characters to be added.

Please keep us up to date on whether it happened to be an out-dated CLI or if declaring the examples yourself using new new orb format fixes this!