candlerb opened a new issue #5683: Cannot create topic under sample/standalone/ns1 URL: https://github.com/apache/pulsar/issues/5683 **Describe the bug** In pulsar 2.4.1 standalone, a "sample/standalone/ns1" namespace is created by default, but I cannot create a topic under it using pulsar-admin - I get a 405 error. **To Reproduce** ``` $ apache-pulsar-2.4.1/bin/pulsar-admin tenants list public sample $ apache-pulsar-2.4.1/bin/pulsar-admin namespaces list sample sample/standalone/ns1 $ apache-pulsar-2.4.1/bin/pulsar-admin topics list sample/standalone/ns1 $ apache-pulsar-2.4.1/bin/pulsar-admin topics create persistent://sample/standalone/ns1/foo 12:21:18.021 [AsyncHttpClient-5-1] WARN org.apache.pulsar.client.admin.internal.BaseResource - [http://localhost:8080/admin/persistent/sample/standalone/ns1/foo] Failed to perform http put request: javax.ws.rs.NotAllowedException: HTTP 405 Method Not Allowed HTTP 405 Method Not Allowed Reason: HTTP 405 Method Not Allowed $ apache-pulsar-2.4.1/bin/pulsar-admin topics create persistent://sample/standalone%2Fns1/foo java.lang.IllegalArgumentException: Invalid named entity: standalone%2Fns1 at org.apache.pulsar.common.naming.NamedEntity.checkName(NamedEntity.java:39) ``` There is also odd behaviour with curl on the `/admin/v2/namespaces/` endpoint: it works for namespaces without slash, but not with slash. ``` ubuntu@ldex-pulsar:~$ curl http://localhost:8080/admin/v2/namespaces/public/default {"auth_policies":{"namespace_auth":...} ubuntu@ldex-pulsar:~$ $ curl http://localhost:8080/admin/v2/namespaces/public/sample/standalone/ns1 <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Error 404 Not Found</title> </head> <body><h2>HTTP ERROR 404</h2> <p>Problem accessing /admin/v2/namespaces/public/sample/standalone/ns1. Reason: <pre> Not Found</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.12.v20180830</a><hr/> </body> </html> $ curl http://localhost:8080/admin/v2/namespaces/public/sample/standalone%2Fns1 <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Error 405 Method Not Allowed</title> </head> <body><h2>HTTP ERROR 405</h2> <p>Problem accessing /admin/v2/namespaces/public/sample/standalone%2Fns1. Reason: <pre> Method Not Allowed</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.12.v20180830</a><hr/> </body> </html> ``` **Expected behavior** Be able to create topic under this namespace. Note that I *can* create another namespace with slashes in its name: ``` $ apache-pulsar-2.4.1/bin/pulsar-admin namespaces create sample/standalone/ns2 $ apache-pulsar-2.4.1/bin/pulsar-admin namespaces list sample sample/standalone/ns1 sample/standalone/ns2 ``` It seems therefore that namespaces with multiple slashes *are* valid in themselves. **Documentation problems** I wasn't expecting to see the "sample" tenant or "sample/standalone/ns1" namespace. They are mentioned in [old documentation](https://pulsar.apache.org/docs/v1.21.0-incubating/getting-started/LocalCluster/), but references have been removed except in passing in the sample output of `show schemas in pulsar` in [SQL getting started](https://pulsar.apache.org/docs/en/sql-getting-started/). In the documentation for [topics](https://pulsar.apache.org/docs/en/concepts-messaging/#topics) or [namespaces](https://pulsar.apache.org/docs/en/concepts-messaging/#namespaces) I couldn't find information on what the rules are for naming namespaces and topics - not even whether slashes are allowed. If slashes are permitted in both namespace and topic, it would lead to ambiguity over how to parse `persistent://sample/foo/bar/baz/qux` into namespace and topic. By experimentation, it *looks* like only the last part is treated as the topic name: ``` $ apache-pulsar-2.4.1/bin/pulsar-admin topics create persistent://public/default/foo/bar 12:31:36.223 [AsyncHttpClient-5-1] WARN org.apache.pulsar.client.admin.internal.BaseResource - [http://localhost:8080/admin/persistent/public/default/foo/bar] Failed to perform http put request: javax.ws.rs.NotAllowedException: HTTP 405 Method Not Allowed HTTP 405 Method Not Allowed Reason: HTTP 405 Method Not Allowed $ apache-pulsar-2.4.1/bin/pulsar-admin topics create persistent://public/default/foo $ ``` But I can't be sure, since I get the same 405 error that I reported above. Finally, the [REST API documentation](https://pulsar.apache.org/docs/en/admin-api-namespaces/) doesn't explain how namespaces are handled in URL paths. If the action was `PUT /admin/v2/namespaces/:tenant/:namespace`, and the tenant was `sample` and the namespace was `standalone/ns1`, then I would expect to encode this as: `PUT /admin/v2/namespaces/sample/standalone%2Fns1` However, experiments suggest otherwise: the components of the namespace become components of the path. ``` $ curl -H "Accept: application/json" http://localhost:8080/admin/persistent/sample/standalone/ns1 [] $ curl -v -H "Accept: application/json" http://localhost:8080/admin/persistent/sample/standalone%2Fns1 * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8080 (#0) > GET /admin/persistent/sample/standalone%2Fns1 HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.58.0 > Accept: application/json > < HTTP/1.1 404 Not Found < Date: Mon, 18 Nov 2019 12:49:20 GMT < Cache-Control: must-revalidate,no-cache,no-store < Content-Length: 0 < Server: Jetty(9.4.12.v20180830) < * Connection #0 to host localhost left intact ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services