Error: Length of base must be equal or exceed the platform minimum url length

Bug #398199 reported by Lucius on 2009-07-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
High
Unassigned

Bug Description

I updated Bazaar on Windows Server 2008 from 1.13-1 to 1.16.1. Client has been on 1.16.1 prior to server update. Since then, client returns:

bzr: ERROR: Server sent an unexpected error: ('error', 'Length of base must be equal or exceed the platform mi
nimum url length (which is 11)')

Falling back to 1.13-1 on server resolves this error.

Any idea, why this error is happening and how to correct it?

Thank you.

Lucius wrote:
> Public bug reported:
>
> I updated Bazaar on Windows Server 2008 from 1.13-1 to 1.16.1. Client
> has been on 1.16.1 prior to server update. Since then, client returns:
>
> bzr: ERROR: Server sent an unexpected error: ('error', 'Length of base must be equal or exceed the platform mi
> nimum url length (which is 11)')
>
> Falling back to 1.13-1 on server resolves this error.
>
> Any idea, why this error is happening and how to correct it?

Hmm. That error comes from bzrlib.urlutils.file_relpath, which I think is only
called by LocalTransport.relpath. So apparently there's a LocalTransport object
with a base URL shorter than “file:///C:/”, which is meant to be impossible on
Windows.

Unfortunately the error doesn't tell us what the problematic URL is. We should
improve the error so that it includes this info, i.e. apply this patch:

=== modified file 'bzrlib/urlutils.py'
--- bzrlib/urlutils.py 2009-04-24 05:08:51 +0000
+++ bzrlib/urlutils.py 2009-07-12 06:25:28 +0000
@@ -75,9 +75,9 @@
     This assumes that both paths are already fully specified file:// URLs.
     """
     if len(base) < MIN_ABS_FILEURL_LENGTH:
- raise ValueError('Length of base must be equal or'
+ raise ValueError('Length of base (%r) must equal or'
             ' exceed the platform minimum url length (which is %d)' %
- MIN_ABS_FILEURL_LENGTH)
+ (base, MIN_ABS_FILEURL_LENGTH))
     base = local_path_from_url(base)
     path = local_path_from_url(path)
     return escape(osutils.relpath(base, path))

Perhaps the new server-jail code since 1.13 is somehow tripping over this?
Although I'd expect that to use a ChrootTransport...

In the meantime you could try adding -Dhpss to the client, which will cause the
client to log the smart server conversation to the .bzr.log (“bzr --version”
will tell you where that log file is kept). It would be helpful to see which
request is triggering this error.

Hmm, I think the definition of either urlutils._win32_local_path_to_url or
urlutils.MIN_ABS_FILEURL_LENGTH is buggy: _win32_local_path_to_url('/') will
return “file:///”, which is clearly less than 11 (MIN_ABS_FILEURL_LENGTH on
Windows). That may be the root cause of this bug (and if so was there in 1.13
too, but purely by luck the offending code path wasn't being hit in 1.13).

Thanks for the bug report!

2009/7/12 Andrew Bennetts <email address hidden>:
> === modified file 'bzrlib/urlutils.py'
> --- bzrlib/urlutils.py  2009-04-24 05:08:51 +0000
> +++ bzrlib/urlutils.py  2009-07-12 06:25:28 +0000
> @@ -75,9 +75,9 @@
>     This assumes that both paths are already fully specified file:// URLs.
>     """
>     if len(base) < MIN_ABS_FILEURL_LENGTH:
> -        raise ValueError('Length of base must be equal or'
> +        raise ValueError('Length of base (%r) must equal or'
>             ' exceed the platform minimum url length (which is %d)' %
> -            MIN_ABS_FILEURL_LENGTH)
> +            (base, MIN_ABS_FILEURL_LENGTH))
>     base = local_path_from_url(base)
>     path = local_path_from_url(path)
>     return escape(osutils.relpath(base, path))

+1

--
Martin <http://launchpad.net/~mbp/>

Dr Paul Gorman (drpaul65) wrote :

I have the same issue. I reran the -Dhss settings:

this is a debug log for diagnosing/reporting problems in bzr
you can delete or truncate this file, or include sections in
bug reports to https://bugs.launchpad.net/bzr/+filebug

Tue 2009-07-14 17:51:07 +1000
0.047 bzr arguments: [u'-Dhss', u'init-repo', u'--no-trees', u'bzr+ssh://Admin@192.168.31.134/repos']
0.047 looking for plugins in C:/Documents and Settings/PaulGo/Application Data/bazaar/2.0/plugins
0.047 looking for plugins in C:/Program Files/Bazaar/plugins
0.172 encoding stdout as sys.stdout encoding 'cp437'
1.812 falling back to default implementation
1.812 failed to load system host keys: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\PaulGo/.ssh/known_hosts'
[ 2860] 2009-07-14 17:51:09.848 INFO: Connected (version 2.0, client OpenSSH_5.1)
2.047 Trying SSH agent key 56C649EFFA38414970651DCC753ED054
[ 2860] 2009-07-14 17:51:10.223 INFO: Authentication (publickey) successful!
[ 2860] 2009-07-14 17:51:10.348 INFO: Secsh channel 1 opened.
2.844 Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 729, in exception_to_return_code
  File "bzrlib\commands.pyo", line 924, in run_bzr
  File "bzrlib\commands.pyo", line 560, in run_argv_aliases
  File "bzrlib\builtins.pyo", line 1695, in run
  File "bzrlib\remote.pyo", line 194, in create_repository
  File "bzrlib\remote.pyo", line 510, in initialize
  File "bzrlib\remote.pyo", line 58, in _call
  File "bzrlib\remote.pyo", line 130, in _translate_error
  File "bzrlib\remote.pyo", line 2653, in _translate_error
UnknownErrorFromSmartServer: Server sent an unexpected error: ('error', 'Length of base must be equal or exceed the platform minimum url length (which is 11)')

2.844 return code 3

Dr Paul Gorman (drpaul65) wrote :

I should have added that if I use sftp as the protocol I do not get this message and the repository is set up correctly.

Vincent Ladeuil (vila) wrote :

'hss' doesn't exist, use 'hpss'.

Dr Paul Gorman wrote:
> I have the same issue. I reran the -Dhss settings:
>
> this is a debug log for diagnosing/reporting problems in bzr
> you can delete or truncate this file, or include sections in
> bug reports to https://bugs.launchpad.net/bzr/+filebug
>
> Tue 2009-07-14 17:51:07 +1000
> 0.047 bzr arguments: [u'-Dhss', u'init-repo', u'--no-trees', u'bzr+ssh://Admin@192.168.31.134/repos']

Sorry, that should be -Dhpss, not -Dhss. -Dhss is not a recognised debug flag,
so no extra info gets added to the log.

-Andrew.

Dr Paul Gorman (drpaul65) wrote :
Download full text (3.3 KiB)

OK.

Thu 2009-07-16 11:16:49 +1000
0.078 bzr arguments: [u'init-repo', u'-Dhpss', u'--no-trees', u'bzr+ssh://Admin@localhost/repos']
0.094 looking for plugins in C:/Documents and Settings/Admin/Application Data/bazaar/2.0/plugins
0.172 looking for plugins in C:/Program Files/Bazaar/plugins
0.219 encoding stdout as sys.stdout encoding 'cp437'
4.078 hpss: Built a new medium: SmartSSHClientMedium
4.078 hpss call: 'mkdir', '/repos', ''
4.078 (to bzr+ssh://Admin@localhost/repos/)
13.219 falling back to default implementation
13.281 failed to load system host keys: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\Admin/.ssh/known_hosts'
[ 2756] 2009-07-16 11:17:08.132 INFO: Connected (version 2.0, client OpenSSH_5.1)
19.656 Trying SSH agent key 23F4B1798D91A0454C049736037116D4
[ 2756] 2009-07-16 11:17:10.507 INFO: Authentication (publickey) successful!
[ 2756] 2009-07-16 11:17:10.710 INFO: Secsh channel 1 opened.

Thu 2009-07-16 11:17:11 +1000
0.093 bzr arguments: [u'serve', u'--inet', u'--directory=/', u'--allow-writes']
21.562 result: ('ok',)
21.562 hpss call: 'BzrDirFormat.initialize', 'repos/'
21.562 (to bzr+ssh://Admin@localhost/repos/)
21.891 result: ('ok',)
0.109 looking for plugins in C:/Documents and Settings/Admin/Application Data/bazaar/2.0/plugins
0.203 looking for plugins in C:/Program Files/Bazaar/plugins
0.250 encoding stdout as osutils.get_user_encoding() 'cp1252'
0.625 Traceback (most recent call last):
  File "bzrlib\smart\request.pyo", line 323, in _call_converting_errors
  File "bzrlib\smart\request.pyo", line 132, in execute
  File "bzrlib\smart\bzrdir.pyo", line 198, in do
  File "bzrlib\bzrdir.pyo", line 848, in open_from_transport
  File "21.891 hpss call: 'BzrDir.open', 'repos/'
21.891 (to bzr+ssh://Admin@localhost/repos/)
21.891 result: ('yes',)
21.891 hpss call: 'BzrDir.create_repository', 'repos/', 'Bazaar pack repository format 1 (needs bzr 0.92)\n', 'True'
21.891 (to bzr+ssh://Admin@localhost/repos/)
21.891 result: ('error', 'Length of base must be equal or exceed the platform minimum url length (which is 11)')
21.891 Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 729, in exception_to_return_code
  File "bzrlib\commands.pyo", line 924, in run_bzr
  File "bzrlib\commands.pyo", line 560, in run_argv_aliases
  File "bzrlib\builtins.pyo", line 1695, in run
  File "bzrlib\remote.pyo", line 194, in create_repository
  File "bzrlib\remote.pyo", line 510, in initialize
  File "bzrlib\remote.pyo", line 58, in _call
  File "bzrlib\remote.pyo", line 130, in _translate_error
  File "bzrlib\remote.pyo", line 2653, in _translate_error
UnknownErrorFromSmartServer: Server sent an unexpected error: ('error', 'Length of base must be equal or exceed the platform minimum url length (which is 11)')

21.891 return code 3
[ 2756] 2009-07-16 11:17:11.726 INFO: HPSS calls: 4 (1 vfs) SmartSSHClientMedium(connected=False, username='Admin', host='localhost', port=None)
bzrlib\smart\request.pyo", line 67, in _pre_open_hook
  File "bzrlib\transport\local.pyo", line 148, in relpath
  File "bzrlib\urlutils...

Read more...

Andrew Bennetts (spiv) wrote :

Thanks for the log. It appears it is happening on BzrDir.open via _pre_open_hook, so it is indeed the new server-side jail triggering it somehow.

For the sake of other people reading, here's the server-side traceback disentangled from the client-side logging:

0.625 Traceback (most recent call last):
  File "bzrlib\smart\request.pyo", line 323, in _call_converting_errors
  File "bzrlib\smart\request.pyo", line 132, in execute
  File "bzrlib\smart\bzrdir.pyo", line 198, in do
  File "bzrlib\bzrdir.pyo", line 848, in open_from_transport
  File "bzrlib\smart\request.pyo", line 67, in _pre_open_hook
  File "bzrlib\transport\local.pyo", line 148, in relpath
  File "bzrlib\urlutils.pyo", line 80, in file_relpath
ValueError: Length of base must be equal or exceed the platform minimum url length (which is 11)

It's happening in response to a ('BzrDir.open', 'repos/') request. This is hopefully enough info that a developer with windows should be able to reproduce?

I've also applied my proposed patch to bzr.dev, so bzr 1.18 should give more information when this happens.

Changed in bzr:
importance: Undecided → High
status: New → Triaged
Andrew Bennetts (spiv) on 2009-07-17
tags: added: win32
Martin Pool (mbp) on 2010-03-18
Changed in bzr:
status: Triaged → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers