Please describe the problem.

I get a "Method not allowed" error when talking through WebDAV with a Nextcloud server hosted in a subdirectory.

What steps will reproduce the problem?

I have configured the remote as a WebDAV server with the instructions from webdav, that is:

$ WEBDAV_USERNAME=anarcat WEBDAV_PASSWORD=REDACTED git annex initremote example.net type=webdav url=https://example.net/nextcloud/remote.php/webdav/ encryption=none --verbose --debug
initremote example.net (testing WebDAV server...) 
git-annex: WebDAV test failed: HttpExceptionRequest Request {
  host                 = "example.net"
  port                 = 443
  secure               = True
  requestHeaders       = [("Authorization","<REDACTED>"),("User-Agent","hDav-using application")]
  path                 = "/"
  queryString          = ""
  method               = "MKCOL"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 405, statusMessage = "Method Not Allowed"}, responseVersion = HTTP/1.1, responseHeaders = [("Date","Sun, 07 Oct 2018 17:56:27 GMT"),("Server","Apache"),("Strict-Transport-Security","max-age=15768000"),("Allow","HEAD,HEAD,GET,HEAD,POST,OPTIONS"),("Content-Length","292"),("Content-Type","text/html; charset=iso-8859-1")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>405 Method Not Allowed</title>\n</head><body>\n<h1>Method Not Allowed</h1>\n<p>The requested method MKCOL is not allowed for the URL /index.html.</p>\n<hr>\n<address>Apache Server at example.net Port 443</address>\n</body></html>\n"): user error
failed
git-annex: initremote: 1 failed

I have tried with and without chunking and with and without extra paths (existing or not) in the url parameter.

I was able to successfully use rclone to configure the remote, with the following config:

[example-nextcloud]
type = webdav
url = https://example.net/nextcloud/remote.php/webdav/
vendor = nextcloud
user = anarcat
pass = *** ENCRYPTED ***

rclone ls then works, which proves that Nextcloud is not misbehaving. I can also create a rclone remote and git-annex is able to store stuff on the nextcloud server through there:

$ git annex initremote rclone type=external externaltype=rclone target=example-nextcloud prefix=git-annex encryption=none rclone_layout=lower
initremote rclone ok
(recording state in git...)
$ git annex copy --to rclone
copy test.txt 2018/10/07 13:31:45 ERROR : : error listing: directory not found 2018/10/07 13:31:45 Failed to size: directory not found
(to rclone...) 
ok
(recording state in git...)

The error message is actually just a warning and the directory is created automatically. I checked and the file is present on the remote so rclone (and therefore webdav) works. Thunar can also browse the host as a Webdav remote without problems.

Unfortunately, the rclone remote doesn't support git-annex-export which makes it unusable for my use case (a publicly visible gallery instead of a backup).

What version of git-annex are you using? On what operating system?

Vanilla Debian buster package:

$ git annex version
git-annex version: 6.20180913
build flags: Assistant Webapp Pairing S3(multipartupload)(storageclasses) WebDAV Inotify DBus DesktopNotify ConcurrentOutput TorrentParser MagicMime Feeds Testsuite
dependency versions: aws-0.19 bloomfilter-2.0.1.0 cryptonite-0.25 DAV-1.3.2 feed-1.0.0.0 ghc-8.2.2 http-client-0.5.13 persistent-sqlite-2.8.1.2 torrent-10000.1.1 uuid-1.3.13 yesod-1.6.0
key/value backends: SHA256E SHA256 SHA512E SHA512 SHA224E SHA224 SHA384E SHA384 SHA3_256E SHA3_256 SHA3_512E SHA3_512 SHA3_224E SHA3_224 SHA3_384E SHA3_384 SKEIN256E SKEIN256 SKEIN512E SKEIN512 BLAKE2B256E BLAKE2B256 BLAKE2B512E BLAKE2B512 BLAKE2B160E BLAKE2B160 BLAKE2B224E BLAKE2B224 BLAKE2B384E BLAKE2B384 BLAKE2S256E BLAKE2S256 BLAKE2S160E BLAKE2S160 BLAKE2S224E BLAKE2S224 BLAKE2SP256E BLAKE2SP256 BLAKE2SP224E BLAKE2SP224 SHA1E SHA1 MD5E MD5 WORM URL
remote types: git gcrypt p2p S3 bup directory rsync web bittorrent webdav adb tahoe glacier ddar hook external
operating system: linux x86_64
supported repository versions: 3 5 6
upgrade supported from repository versions: 0 1 2 3 4 5
local repository version: 5

The server is running Nextcloud 14 on Debian stable, I assume. I have checked and Nextcloud definitely supports the MKCOL verb.

Please provide any additional information below.

Here's the debug output when creating the remote. It seems it fails on the MKCOL verb, which is denied by the server:

# If you can, paste a complete transcript of the problem occurring here.
# If the problem is with the git-annex assistant, paste in .git/annex/daemon.log
$ WEBDAV_USERNAME=anarcat WEBDAV_PASSWORD=REDACTED git annex initremote example.net type=webdav url=https://example.net/nextcloud/remote.php/webdav/ encryption=none --verbose --debug
[2018-10-07 13:22:30.794584586] read: git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","show-ref","git-annex"]
[2018-10-07 13:22:30.797203114] process done ExitSuccess
[2018-10-07 13:22:30.79734081] read: git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","show-ref","--hash","refs/heads/git-annex"]
[2018-10-07 13:22:30.799738604] process done ExitSuccess
[2018-10-07 13:22:30.800004526] read: git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","log","refs/heads/git-annex..6f8555ce9bda4c1a0e8f1cfdb5652a868f6bfd53","--pretty=%H","-n1"]
[2018-10-07 13:22:30.803058278] process done ExitSuccess
[2018-10-07 13:22:30.803540459] chat: git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","cat-file","--batch"]
[2018-10-07 13:22:30.811553668] chat: git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","cat-file","--batch-check=%(objectname) %(objecttype) %(objectsize)"]
initremote example.net (testing WebDAV server...) [2018-10-07 13:22:32.999000982] getProps /
[2018-10-07 13:22:33.202572045] mkCol /

git-annex: WebDAV test failed: HttpExceptionRequest Request {
  host                 = "example.net"
  port                 = 443
  secure               = True
  requestHeaders       = [("Authorization","<REDACTED>"),("User-Agent","hDav-using application")]
  path                 = "/"
  queryString          = ""
  method               = "MKCOL"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 405, statusMessage = "Method Not Allowed"}, responseVersion = HTTP/1.1, responseHeaders = [("Date","Sun, 07 Oct 2018 17:22:33 GMT"),("Server","Apache"),("Strict-Transport-Security","max-age=15768000"),("Allow","HEAD,HEAD,GET,HEAD,POST,OPTIONS"),("Content-Length","292"),("Content-Type","text/html; charset=iso-8859-1")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>405 Method Not Allowed</title>\n</head><body>\n<h1>Method Not Allowed</h1>\n<p>The requested method MKCOL is not allowed for the URL /index.html.</p>\n<hr>\n<address>Apache Server at example.net Port 443</address>\n</body></html>\n"): user error
failed
[2018-10-07 13:22:33.235310398] process done ExitSuccess
[2018-10-07 13:22:33.235869777] process done ExitSuccess
git-annex: initremote: 1 failed
# End of transcript or log.

Notice how the server is hosted on a subdirectory of example.net (a placeholder name of course, my hosting provide wants to stay private ;). Maybe that's the problem? The error message says MKCOL is not allowed for the URL /index.html, so that is probably example.net/index.html responding. I suspect it's failing to do getProps / right before and assumes the WebDAV server does not have a root directory (which makes no sense - the Nextcloud server endpoint is actually at /nextcloud/remote.php/webdav). I would argue that getProps / should never fail or rather, we should assume the server is hosted in a subdirectory in that case.

Incidentally, the owncloudannex remote also fails, but at the upload stage - it gives a 500 error message. But since it doesn't support the exporttree functionality, it's out of the question here as well.

Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)

I use git-annex every day! I hope to write a glowing review for LWN soon. ;) Cheers and hi joey! :)