0

I'm trying to publish a minor update to the Atom package and I keep on getting "The header content contains invalid characters"

What I did: cloned the repo, set remote branch, fetch branches, pull content. modify stuff. change the version in package.json. git add. git commit. git push.

and then I used apm publish minor.

I keep on getting this annoying error and I can't find anything on it on the internet. I dont even know how to get more details, what is even the header? is it package.json?

this is how the package.json looks by default for atom packages:

{
  "name": "my-test-package",
  "main": "./lib/my-test-package",
  "version": "0.0.0",
  "description": "A short description of your package",
  "keywords": [
  ],
  "activationCommands": {
    "atom-workspace": "my-test-package:toggle"
  },
  "repository": "https://github.com/atom/my-test-package",
  "license": "MIT",
  "engines": {
    "atom": ">=1.0.0 <2.0.0"
  },
  "dependencies": {
  }
}

the only thing I changed here was the 2nd digit from the version.

mrwhite
  • 105
  • 12

1 Answers1

1

This question is pretty old now, but it's still one of the top results for this issue -- so I'm going to add my solution.

TLDR: You may have accidentally added an illegal character (newline, etc.) to your authentication token. You can fix this by:

  1. Delete the old authentication token from whatever keyring your OS uses. In Windows 10, this is under Control Panel\User Accounts\Credential Manager.
  2. The command 'apm publish minor' should re-prompt for your authentication token. When it does, hit backspace a few times, and then re-enter the token. Take care that there are not any invisible characters at the end of your token.

And that's it -- your package should now be published!


Long version:

When apm publish detects an issue with your package.json file, it will throw an Error parsing package.json file: and give you a location for the bad token/character. The header content that is failing in this case is sent before the actual json, and includes things like your authentication token.

In general, then, the thing that will be broken about this header is the one thing you've changed -- the authentication token. When an unexpected character (usually an invisible character) is added to your token, it breaks the processing of this pre-json header. And since your computer helpfully saved this broken token to a keyring, you'll be stuck endlessly receiving this mysterious error.

Alvor Vox
  • 11
  • 1