Skip to content

[BUG] input_datetime custom attribute value not checked by the front-end #1071

@ineldx

Description

@ineldx

Describe the bug

The input_datetime custom attribute needs a value tag (usually set to empty string "") to work properly.
The front end doesn't validate the presence of this value, which gets the back to throw an ambiguous error 500, only visible in stderr.
Additionally, the documentation isn't clear about this tag being required, as only the input_checkbox seems to need it, and no mandatory tags are mentioned for input_datetime.

Python traceback

Traceback (most recent call last):                                                                    
  File "/opt/venv/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app                   
    response = self.full_dispatch_request()                                                           
  File "/opt/venv/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request      
    rv = self.handle_user_exception(e)                                                                
  File "/opt/venv/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request      
    rv = self.dispatch_request()                                                                      
  File "/opt/venv/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request           
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)                          
  File "/iriswebapp/app/util.py", line 747, in wrap                                                   
    return f(*args, **kwargs)                                                                         
  File "/iriswebapp/app/blueprints/manage/manage_attributes_routes.py", line 127, in update_attribute 
    attr_contents, logs = validate_attribute(attr_content)                                            
  File "/iriswebapp/app/datamgmt/manage/manage_attribute_db.py", line 267, in validate_attribute      
    f'but got {type(data[tab][field]["value"])}')                                                     
KeyError: 'value'                                                                                     

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'Advanced', 'Custom Attributes'
  2. Click on 'Case' or any other 'Attribute'
  3. Write the JSON below in the 'Attribute Definition'
  4. Click on 'Complet Overwrite', 'Partial Overwrite' or 'Update' to trigger the error.

Json

{
      "A": {
          "B": {
                "type": "input_datetime",
                "mandatory": false
          }
}

Expected behavior

The presence of this required value should be checked by the front-end, and if missing, should raise an error.
A popup already exists for other missing tags that are required, ex:

Found errors in attribute
Logs:
    [REDACTED] -> [REDACTED] of type input_select is missing the mandatory "value" tag

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions