Bug 50025 - [UDM HTTP API] add form ignores passed position argument
[UDM HTTP API] add form ignores passed position argument
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - REST API
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-1-errata
Assigned To: Florian Best
UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-08-19 15:25 CEST by Daniel Tröder
Modified: 2019-10-02 16:06 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2019-08-19 15:25:08 CEST
The object template retrieved through the add form does not contain the "position" argument that was passed to it. If such a form is used to create an object it will no be placed in the LDAP tree in the expected position.

Add support for for the "position" argument and deliver object templates with the "position" set accordingly.
Comment 1 Florian Best univentionstaff 2019-08-19 19:49:45 CEST
Okay, position is now set in the response of create-form.

Fixed in, no package build, will be done soon via Bug #27816:
b606a4c3d3c9 | Bug #50025: Bug #27816: make sure create form returns the given position
Comment 2 Florian Best univentionstaff 2019-08-29 17:37:00 CEST
Btw: the real issue might be that the form did contain a empty position? Now the default position is inserted.

Why do you want to set the position already in the creation template?
I think it would be better to leave this completely unparametrized.
The template gives the defaults, if you want to set something else you can modify the response.
Comment 3 Daniel Tröder univentionstaff 2019-08-30 09:05:23 CEST
(In reply to Florian Best from comment #2)
> Btw: the real issue might be that the form did contain a empty position? Now
> the default position is inserted.
Getting the default position is very helpful.
But it should only happen, when no custom position was requested.
If I pass in a custom position, it should not be returned like I sent it.

> Why do you want to set the position already in the creation template?
> I think it would be better to leave this completely unparametrized.
> The template gives the defaults, if you want to set something else you can
> modify the response.
That would be fine as well.
But then the API should reject the "position" argument with an error. Accepting something and then ignoring it, leads to false expectations by the client.
Comment 4 Florian Best univentionstaff 2019-09-06 17:41:22 CEST
I think we should support both. superordinate and position is now optional.
Therefore I had to delay the validation of the superordinate from __init__ into create() and modify().
Otherwise:

[I 190826 15:51:18 web:1971] 200 GET /udm/dns/ptr_record/ (127.0.0.1) 4.12ms      
[E 190826 15:51:18 web:1548] Uncaught exception GET /udm/dns/ptr_record/add (127.0.0.1)
    HTTPServerRequest(protocol='http', host='master100.school.dev', method='GET', uri='/udm/dns/ptr_record/add', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'X-Umc-Https': 'on', 'Via': '1.1 master100.school.dev', 'Accept-Language': 'en-US', 'Accept-Encoding': 'gzip
, deflate', 'X-Forwarded-Host': 'master100.school.dev', 'X-Forwarded-For': '10.200.27.100', 'Host': 'master100.school.dev', 'Accept': 'application/hal+json; q=1, application/json; q=0.9; text/html; q=0.2, */*; q=0.1', 'User-Agent': 'univention.cli/4.4-1-errata241', 'Connec
tion': 'close', 'X-Forwarded-Proto': 'https', 'X-Forwarded-Server': 'master100.school.dev', 'X-Forwarded-Ssl': 'on', 'Authorization': 'Basic QWRtaW5pc3RyYXRvcjp1bml2ZW50aW9u'})
    Traceback (most recent call last):                                              
      File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1469, in _execute                                  
        result = yield result                     
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run                             
        value = future.result()   
      File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result                 
        raise_exc_info(self._exc_info)                                                                                                                             
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 270, in wrapper
        result = func(*args, **kwargs)                                    
      File "/usr/lib/pymodules/python2.7/univention/management/modules/udm/module.py", line 3005, in get
        result.update(self.get_create_form(module, template=template, position=self.request.query_arguments.get('position'), superordinate=self.request.query_arguments.get('superordinate')))
      File "/usr/lib/pymodules/python2.7/univention/management/modules/udm/module.py", line 3053, in get_create_form
        obj = module.module.object(dn, self.ldap_connection, ldap_position, superordinate=superordinate)
      File "/usr/lib/pymodules/python2.7/univention/admin/handlers/dns/ptr_record.py", line 192, in __init__
        univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes=attributes)
      File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 248, in __init__
        self._validate_superordinate()
      File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 1009, in _validate_superordinate
        raise univention.admin.uexceptions.insufficientInformation(_('No superordinate object given'))
    insufficientInformation: No superordinate object given


univention-directory-manager-modules (14.0.13-12)
d9f4d0255df7 | Bug #27816: Bug #50025: the check for a valid superordinate is now delayed to the creation or modification of objects.

univention-management-console-module-udm (9.0.12-24)
b606a4c3d3c9 | Bug #50025: Bug #27816: make sure create form returns the given position

univention-directory-manager-modules.yaml
d9f4d0255df7 | Bug #27816: Bug #50025: the check for a valid superordinate is now delayed to the creation or modification of objects.
Comment 5 Florian Best univentionstaff 2019-10-02 16:06:34 CEST
UCS 4.4-2 has been released:
 https://docs.software-univention.de/release-notes-4.4-2-en.html
 https://docs.software-univention.de/release-notes-4.4-2-de.html

If this error occurs again, please use "Clone This Bug".