#6647 batch param compatibility is incorrect
Closed: fixed Opened by rcritten.

The definition of the batch params all define methods as Str. It has never been a Str. It was defined as Any until recently when it was refined to Dict.

This causes the batch command in ipalib on 4.4 to fail to work because methods is not a Str (it doesn't even get far enough to make a request, it blows up validating the input).

Here is the output from the sample program:

Traceback (most recent call last):
  File "batch.py", line 10, in <module>
    res = api.Command.batch(batch)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 449, in __call__
    return self.__do_call(*args, **options)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 470, in __do_call
    params = self.convert(**params)
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 671, in convert
    (k, self.params[k].convert(v)) for (k, v) in kw.items()
  File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 671, in <genexpr>
    (k, self.params[k].convert(v)) for (k, v) in kw.items()
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 831, in convert
    convert(v) for v in value if not _is_null(v)
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 831, in <genexpr>
    convert(v) for v in value if not _is_null(v)
  File "/usr/lib/python2.7/site-packages/ipalib/parameters.py", line 1445, in _convert_scalar
    raise ConversionError(name=self.name, error=ugettext(self.type_error))
ipalib.errors.ConversionError: invalid 'methods': must be Unicode text

demonstration script
batch.py

Following works for me on web ui:. Is it an issue only on client side?

{
  "method":"batch","params":[[
    {"method":"user_show","params":[["aa"],{"no_members":true}]},  
    {"method":"user_show","params":[["admin"],{"no_members":true}]},
    {"method":"user_show","params":[["fbar"],{"no_members":true}]},
    {"method":"user_show","params":[["testuser"],{"no_members":true}]},
    {"method":"user_show","params":[["testuser1"],{"no_members":true}]}
  ],{"version":"2.217"}]
}

Yes, the bug is in the ipalib client-side compat code definition. It defines methods as Str and it should be either Any or Dict depending on version (I didn't dig into the details on when it changed from Any to Dict).

master:

  • 19060db1b8fa9d1d3e8f3ac3fcd1f387e9a39c94 compat: fix Any params in batch and dnsrecord

Metadata Update from @rcritten:
- Issue assigned to jcholast
- Issue set to the milestone: FreeIPA 4.5

Repasting content of batch.py:

from ipalib import api
from ipalib import errors
api.bootstrap(context='cli')
api.finalize()
api.Backend.rpcclient.connect()
batch = [{u'params': [(u'test.example.com',), {u'force': u'True'}], u'method': u'host_add'}]
res = api.Command.batch(batch)

Metadata Update from @pvoborni:
- Custom field affects_doc reset
- Custom field tester adjusted to wanted
- Issue close_status updated to: None (was: Fixed)

Metadata Update from @pvoborni:
- Custom field affects_doc reset
- Issue close_status updated to: fixed

Metadata Update from @pvoborni:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1428472 (was: 0)

Metadata Update from @pvoborni:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1428472 (was: 0)

Issue linked to Bugzilla: Bug 1428472

ipa-4-4:

  • e3b49abfe7a8d9540d77ed355595d9e44a3bdd27 compat: fix Any params in batch and dnsrecord

Metadata Update from @jcholast:
- Issue set to the milestone: FreeIPA 4.4.4 (was: FreeIPA 4.5)

Metadata