Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespaces with a leading '_' character result in cloudant failures #2830

Open
mdeuser opened this issue Oct 4, 2017 · 6 comments
Open

Namespaces with a leading '_' character result in cloudant failures #2830

mdeuser opened this issue Oct 4, 2017 · 6 comments

Comments

@mdeuser
Copy link
Contributor

mdeuser commented Oct 4, 2017

When creating an action (or any other entity) in a namespace having a name that has a _ as the leading character, the controller encounters the following error when saving the entity document in cloudant

[ERROR] [#tid_385] [CouchDbRestStore] [PUT] 'whisks' failed to put document: 'id: _xyz/abc, rev: null'; http status: '400 Bad Request' [marker:database_saveDocument_error:18:3]

As shown, the cloudant document id is based off of the entity's fully qualified name - which starts with the namespace name; in this example, the namespace is _xyz. According to https://console.bluemix.net/docs/services/Cloudant/api/document.html#documents cloudant document _id values may not have a leading _ character, resulting in the cloudant request failure.

Possible solutions:

  • Do not allow namespaces with leading _ characters
  • Escape any leading _ character in the _id field
@rabbah
Copy link
Member

rabbah commented Oct 4, 2017

I would change the REGEX, that should be enough. https://github.com/apache/incubator-openwhisk/blob/d86c415a1d9a4eaa2061eac3a6ce99f24ba390f9/common/scala/src/main/scala/whisk/core/entity/EntityPath.scala#L193

The controller does not create subjects. And if one attempts to do so via wskadmin, it will be rejected for the reasons noted above.

@mdeuser
Copy link
Contributor Author

mdeuser commented Oct 4, 2017

Is that regex used when

  • REST API is invoked with _ as the namespace (i.e. controller uses the auth key to look up the namespace)
  • REST API is invoked with an explicit namespace having _ as the first character

Other related changes:

@rabbah
Copy link
Member

rabbah commented Oct 4, 2017

All _ namespaces are resolved early in the controller and will be rejected if the namespace is therefore not conforming. And using an explicit leading underscore in a name should not match routes in the controller either. TDD FTW.

@markusthoemmes
Copy link
Contributor

As a quick note: wskadmin will happily create the namespace, the Controller will only fail on usage of that created namespace.

@rabbah
Copy link
Member

rabbah commented Oct 4, 2017

It should not:

> wskadmin user create _guest
Failed to create subject ({"error":"illegal_docid","reason":"Only reserved document ids may start with underscore."})

because the subject is the primary index and hence fails the invariant couch/cloudant assert.

@rabbah
Copy link
Member

rabbah commented Oct 4, 2017

You probably mean creating a namespace vs a subject? In which case, yes. We should shut that down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants