-
Type: Bug
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 2.0.0
-
Fix Version/s: None
-
Component/s: Core
-
Team:DRIVE
-
Sprint:nxdrive next
I am opening that ticket for thinking, it may be simply closed as "won't fix".
We stumble upon a weird case (we may have encountered it years ago, but my memory is not so efficient).
Here is some code to create a Workspace:
import logging from nuxeo.client import Nuxeo from nuxeo.models import Document # Enable logging to ease debug logging.basicConfig(level=logging.DEBUG) # Connection host = "http://<HOST>" # Note the HTTP, it's important auth = ("user", "pwd") nuxeo = Nuxeo(host=host, auth=auth) # Create a workspace new_ws = Document(name="Tests", type="Workspace", properties={"dc:title": "Tests"}) workspace = nuxeo.documents.create(new_ws, parent_path="/default-domain/workspaces") print(workspace)
The script will print a valid Document. But it is misleading as it will actually be the metadata of the specified parent_path ("/default-domain/workspaces") (no document has been created at the end).
What happened is that the POST call returned a HTTP 301 (move permanently) error code, then did a GET on the parent path, thus returning metadata of the parent path.
Logs:
DEBUG:nuxeo.client:Calling POST 'http://<HOST>/nuxeo/api/v1/repo/default/path/default-domain/workspaces' DEBUG:nuxeo.utils:Response from 'http://<HOST>/nuxeo/api/v1/repo/default/path/default-domain/workspaces' [301]: '301 Moved Permanently' ... DEBUG:nuxeo.utils:Response from 'https://<HOST>:443/nuxeo/api/v1/repo/default/path/default-domain/workspaces' [200]: '{"entity-type":"document",...}"'
I know this is not typical code from customers. And keeping support for HTTP is interesting for local tests. Maybe should the client prohibit to follow redirections (using the allow_redirects=False to requests functions)?
As an example, curl doen't follow redirections by default.