Announcement

Collapse
No announcement yet.

Error 400 v7.2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error 400 v7.2

    Hello,

    I am seeing this error on my custom entities:

    Error 400: Bad request
    Backend validation failure.

    Field: flags
    Validation: pattern

    Any suggestions?

    Brad

  • #2
    Hi,

    What field type? What values produce the error?

    Comment


    • #3
      Hello,

      One is a many-to-many and another is a one-to-many relationship.

      Another error 400 is happening on an Enum field. This happens when I attempt to duplicate.

      Error 400: Bad request
      Backend validation failure.

      Field: kitsRequested
      Validation: valid

      ​​
      ​​
      Brad​

      Comment


      • #4
        Was metadata of these fields edited manually? It's not enough information for me to know what exactly is happening. Metadata of this fields would be helpful to see.

        Comment


        • #5
          If it's manual customization, please consider debugging. I'm extremely busy with work these days. From early morning to late night daily

          Comment


          • #6
            Yuri,

            It isn't custom edited except for colors. THat doesnt seem to be what is affecting the server. Here is the metadata of the enum field.

            Code:
                    "kitsRequested": {
                        "type": "enum",
                        "options": [
                            "",
                            "1",
                            "2",
                            "3",
                            "4",
                            "5",
                            "6",
                            "7",
                            "8",
                            "9",
                            "10",
                            "10+"
                        ],
                        "optionColors": {
                            "1": "FFFFFF",
                            "2": "FFFFFF",
                            "3": "FFFFFF",
                            "4": "FFFFFF",
                            "5": "FFFFFF",
                            "6": "FFFFFF",
                            "7": "FFFFFF",
                            "8": "FFFFFF",
                            "9": "FFFFFF",
                            "10": "FFFFFF",
                            "": "FFFFFF",
                            "10+": "FFFFFF"
                        },
                        "default": "",
                        "isCustom": true,
                        "audited": true
                    },
            ​
            Here is the metadata for the contact many-to-many link:

            Code:
                    "contacts": {
                        "type": "linkMultiple",
                        "layoutDetailDisabled": false,
                        "layoutListDisabled": true,
                        "layoutMassUpdateDisabled": false,
                        "importDisabled": false,
                        "noLoad": false,
                        "isCustom": true
                    },
            ​
            I will keep tinkering until I figure out what is going on.

            Comment


            • alexisc
              alexisc commented
              Editing a comment
              had the same error, field "default" cannot be empty, fixed it and everything worked

            • telecastg
              telecastg commented
              Editing a comment
              Following alexisc example, I would suggest trying using " " instead of "" as option value and as default value.

          • #7
            Could you also provide "flags" field metadata?

            Comment


            • #8
              The errors are thrown by a new set of "FieldValidators" classes that execute specific validation rules by field type. https://github.com/espocrm/espocrm/t...ieldValidators

              One of Espo's greatest features, is that it can be easily customized to provide a unique solution for each user.

              It would be great if these rules could be documented (explained in the documentation) so everyone gets more familiar with this new functionality and can adjust existing or new customized fields..
              Last edited by telecastg; 09-14-2022, 06:40 PM.

              Comment


              • yuri
                yuri commented
                Editing a comment
                Rule is simple. For enum you can store only values listed in field options. The same for link-multiple enum columns. I'm not sure it needs documenting as it was rather a fault of the previous versions of not having such validations.

                Field Validators are not new (they are pretty bad designed actually, I'd call them a legacy code), they were there but less validations were implemented.
                Last edited by yuri; 09-14-2022, 06:47 PM.

            • #9
              I have this error in V7.2.4 for fields that are filled by Workflows. It seems that the instruccions in he Worekflows do not work, or are not recognized by some field validator, or something else. Had to restore last night V7.1.11 backup in order to continue working normally.

              Click image for larger version

Name:	image.png
Views:	968
Size:	144.4 KB
ID:	83656
              Last edited by jeamado; 10-01-2022, 07:39 PM.

              Comment


              • telecastg
                telecastg commented
                Editing a comment
                If the field "Tipo de Motivo" is enum and you don't want to have static options (hard coded in metadata) set the "options" parameter for the field as "null", this way the validator will not trigger any errors based on the values of the field.

                I had the same case for a field where the options are defined dynamically based on the value of a different field.

            • #10
              I have this error as well in various custom entities, not always for the same reason. One reason ocurrs, when I try to save a new record for the entity. In that entity the "name" field is mandatory. The error indicates, that the validation failed, although the field is filled.
              When I unmark the mandatory checkbox in the entity manager for that field, the eror does not happen anymore.

              The error also does not happen, if I modify an existing record, even if the modification is in the mandatory field.

              In another occasion the error occurred from a enum field, where I pull values from another entity (as well an enum field).

              Comment


              • rabii
                rabii commented
                Editing a comment
                i have the same issue exactly what you described. a field of relationship is failing when creating new record although the validation is disabled.

              • jeamado
                jeamado commented
                Editing a comment
                shalmaxb "When I unmark the mandatory checkbox in the entity manager for that field, the eror does not happen anymore".

                I have anyhow the same error uncheck the "mandatory" field or not when it have to be filled automatically by a Workflow.

            • #11
              Originally posted by yuri View Post
              If it's manual customization, please consider debugging. I'm extremely busy with work these days. From early morning to late night daily
              Hey yuri

              Hey we are experiencing the same error, basically we are using an extension from Elba which allow to create pivot tables. we have 3 entities (Contract - Service and ContractService) the way it is set up is to allow to select services from the contract using the pivot table ContractService and there is a relationship between contract and contractservice as One to Many (one contract to many contractservices) we are using the field contractservices on the contract layout to allow to select a service and add additional data into using the pivot table. This field used to work fine but now it is producing error as you can see on attached screenshot. i have debugged and this is the message from the log WARNING: E_WARNING: Undefined array key "service" please note that the service is another relationship field between service and contractservice entities one service to many contractservice it seems that this is what causing the issue.

              this is the metadata of the field contractServices:
              Code:
              "contractServices": {
                  "layoutListDisabled": true,
                  "layoutDetailDisabled": false,
                  "type": "linkMultiple",
                  "layoutMassUpdateDisabled": false,
                  "noLoad": false,
                  "importDisabled": false,
                  "isCustom": true,
                  "rowActionItems": [
                      "remove"
                  ],
                  "orderBy": "createdAt",
                  "required": false,
                  "enableForm": true,
                  "layout": "listSmall",
                  "middleLink": "service",
                  "copyFields": [
                      "assignedUser",
                      "createdBy",
                      "createdAt",
                      "modifiedAt",
                      "modifiedBy",
                      "name"
                  ],
                  "footerSumFields": [],
                  "enableSelect": true,
                  "fields": [],
                  "buttonsPosition": "bottom",
                  "order": "asc"
              },​
              Any hint on how to solve this.

              Many thanks
              Attached Files
              Rabii
              Web Dev

              Comment


              • #12
                The error says it is because a problem with the pattern. This was recently introduced in 7.2. In the entity manager you will see now in the field a new value "pattern", which makes possible to enter a certain mandatory pattern like e.g. 4 digits or alike. Have a look in the shown fields, if you could put in an appropriate pattern and see, if that solves the problem.

                As this value did not exist before, it is not present in existing records. Maybe (maybe!) in this direction you could solve the problem.

                Comment


                • #13
                  I have already went that way but there was no pattern on the field. Tried few different ways but seems that none has worked. Main issue is the service field on contractservice entity the system report that it is undefined array key ‘service’.
                  Rabii
                  Web Dev

                  Comment


                  • #14
                    I think that the problem might be because the field contractServices is defined as a field type link multiple and the system might be expecting an array of ids of the records that make the "many" side of the relationship (thus the "pattern error") ....

                    For general information, when a link multiple relationship is created, for example like One to Many, the entity in the "One" side will have two additional attributes that contain the information about the "Many" linked entities.

                    For example: I have a custom "Control Board Display" entity that is liked to many "CriteriaConditiionGroup" entities, and when I look at the "ControlBoardDisplay" model in the console, it has the attributes "criteriaConditionGroupsIds" containing a list of the ids of linked CriteriaConditionGroup entities and the attribute "criteriaConditionGroupsNames" containing the names of the linked CriteriaConditionGroup records.

                    So even though, I did not create or specify a field "criteriaCondiitionGroupsIds" in metadata, the system created it when building the links, and the validation enforcement for that field will check that the ids conform to the regex pattern specified by Espo.

                    This is the code performing the link multiple pattern validation: https://github.com/espocrm/espocrm/b...leType.php#L66

                    Because of the time spent attempting to solve these issues, given the lack of documentation, in our case, we have opted to wait out before moving forward with 7.2 until this new "validation" enforcement mechanism is more mature and understood so we can adapt our code appropriately.

                    Aside from that option, the other alternative at this time, would be to remove/block the code that adds the validation for now.​
                    Last edited by telecastg; 11-01-2022, 06:38 PM. Reason: Added more information about model attributes created by links

                    Comment


                    • rabii
                      rabii commented
                      Editing a comment
                      seems that solved the issue as you said i have deactivated code for checking validation pattern until it is mature and works better.

                      thanks for putting me into the right direction.

                    • telecastg
                      telecastg commented
                      Editing a comment
                      You're very welcome

                    • yuri
                      yuri commented
                      Editing a comment
                      You send some non-ID data in the field that is supposed to receive IDs or you use non-standard IDs. If you use non-standard IDs, consider changing allowed ID regexp pattern in the metadata.

                      What is immature with the validation in this case? You don't consider the customization immature, but the validation.
                      Last edited by yuri; 10-25-2022, 07:12 AM.

                  • #15
                    hi all, we had this very same issue upon updating yesterday to the newest version. And it was solved at ESPO by changing and then changing back the requirement of that field. I know it's not a super accurate answer, but probably something got "stuck" on the definition of that field.

                    Comment

                    Working...
                    X