apache / openwhisk

Apache OpenWhisk is an open source serverless cloud platform
https://openwhisk.apache.org/
Apache License 2.0
6.54k stars 1.17k forks source link

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

Open mdeuser opened 7 years ago

mdeuser commented 7 years ago

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:

rabbah commented 7 years ago

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 commented 7 years ago

Is that regex used when

Other related changes:

rabbah commented 7 years ago

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 commented 7 years ago

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

rabbah commented 7 years ago

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 commented 7 years ago

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