Uploaded image for project: 'COmanage'
  1. COmanage
  2. CO-2451

Unable to delete Address attached to CoPersonRole via REST API

    XMLWordPrintable

Details

    Description

      Registry throws a 500 error when deleting an Address attached to a CoPersonRole.

      Here is the add request :

        [Request] POST https://comanage-registry:443/registry/addresses.json {
          "RequestType": "Addresses",
          "Version": "1.0",
          "Addresses": [
            {
              "Version": "1.0",
              "Street": "Street 2",
              "Room": "Room 2",
              "Locality": "Locality 2",
              "State": "State 2",
              "PostalCode": "PostalCode 2",
              "Country": "Country 2",
              "Type": "postal",
              "Description": "Description",
              "Person": {
                "Type": "CoRole",
                "Id": "2"
              }
            }
          ]
        }
        [Request Headers] {"Content-Type":"application/json"}
        [Page] https://comanage-registry:443/registry/addresses.json
        [Response] 201
        [Request Cookies] {"CAKEPHP":"182878e156aa7cf458c4e50a526f3ef6"}
        [Response Headers] {"Date":["Tue, 21 Jun 2022 23:12:41 GMT"],"Server":["Apache/2.4.53 (Debian)"],"Strict-Transport-Security":["max-age=63072000; includeSubDomains"],"X-Powered-By":["PHP/7.3.33"],"Content-Length":["77"],"Content-Type":["application/json; charset=UTF-8"]}
        [Response] {"ResponseType":"NewObject","Version":"1.0","ObjectType":"Address","Id":"2"}

      Here is the view request :

        [Request] GET https://comanage-registry:443/registry/addresses/2.json
        [Request Headers] {"Content-Type":"application/json"}
        [Page] https://comanage-registry:443/registry/addresses/2.json
        [Response] 200
        [Request Cookies] {"CAKEPHP":"182878e156aa7cf458c4e50a526f3ef6"}
        [Response Headers] {"Date":["Tue, 21 Jun 2022 23:12:42 GMT"],"Server":["Apache/2.4.53 (Debian)"],"Strict-Transport-Security":["max-age=63072000; includeSubDomains"],"X-Powered-By":["PHP/7.3.33"],"Content-Length":["418"],"Content-Type":["application/json; charset=UTF-8"]}
        [Response] {"ResponseType":"Addresses","Version":"1.0","Addresses":[{"Version":"1.0","Id":2,"Street":"Street 2","Room":"Room 2","Locality":"Locality 2","State":"State 2","PostalCode":"PostalCode 2","Country":"Country 2","Description":"Description","Type":"postal","Person":{"Type":"CoRole","Id":2},"Created":"2022-06-21 23:12:41","Modified":"2022-06-21 23:12:41","Revision":0,"Deleted":false,"ActorIdentifier":"co_1.api-user"}]}

      Here is the delete request :

        [Request] DELETE https://comanage-registry:443/registry/addresses/2.json []
        [Request Headers] {"Content-Type":"application/json"}
        [Page] https://comanage-registry:443/registry/addresses/2.json
        [Response] 500
        [Request Cookies] {"CAKEPHP":"182878e156aa7cf458c4e50a526f3ef6"}
        [Response Headers] {"Date":["Tue, 21 Jun 2022 23:12:42 GMT"],"Server":["Apache/2.4.53 (Debian)"],"Strict-Transport-Security":["max-age=63072000; includeSubDomains"],"X-Powered-By":["PHP/7.3.33"],"Content-Length":["1818"],"Connection":["close"],"Content-Type":["application/json; charset=UTF-8"]}
        [Response] {
            "code": 500,
            "name": "SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block",
            "message": "SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block",
            "url": "/registry/addresses/2.json",
            "error": {
                "errorInfo": [
                    "25P02",
                    7,
                    "ERROR:  current transaction is aborted, commands ignored until end of transaction block"
                ],
                "queryString": "SELECT \"Address\".\"id\" AS \"Address__id\", \"Address\".\"street\" AS \"Address__street\", \"Address\".\"room\" AS \"Address__room\", \"Address\".\"locality\" AS \"Address__locality\", \"Address\".\"state\" AS \"Address__state\", \"Address\".\"postal_code\" AS \"Address__postal_code\", \"Address\".\"country\" AS \"Address__country\", \"Address\".\"description\" AS \"Address__description\", \"Address\".\"type\" AS \"Address__type\", \"Address\".\"language\" AS \"Address__language\", \"Address\".\"co_person_role_id\" AS \"Address__co_person_role_id\", \"Address\".\"org_identity_id\" AS \"Address__org_identity_id\", \"Address\".\"co_department_id\" AS \"Address__co_department_id\", \"Address\".\"organization_id\" AS \"Address__organization_id\", \"Address\".\"source_address_id\" AS \"Address__source_address_id\", \"Address\".\"created\" AS \"Address__created\", \"Address\".\"modified\" AS \"Address__modified\", \"Address\".\"address_id\" AS \"Address__address_id\", \"Address\".\"revision\" AS \"Address__revision\", \"Address\".\"deleted\" AS \"Address__deleted\", \"Address\".\"actor_identifier\" AS \"Address__actor_identifier\" FROM \"public\".\"cm_addresses\" AS \"Address\"   WHERE \"Address\".\"id\" = 2    LIMIT 1"
            }
        }

      Here is the PostgreSQL log :

      2022-06-22 22:03:55.497 UTC [183] LOG:  execute pdo_stmt_0000003c: INSERT INTO "public"."cm_history_records" ("co_person_id", "co_person_role_id", "org_identity_id", "co_group_id", "co_email_list_id", "co_service_id", "actor_co_person_id", "action", "actor_api_user_id", "comment", "modified", "created", "history_record_id", "revision", "deleted", "actor_identifier") VALUES (2, 2, NULL, NULL, NULL, 1, NULL, 'ECPM', NULL, 'Address Deleted: Street: Street 2 > Null;Room: Room 2 > Null;City: Locality 2 > Null;State: State 2 > Null;ZIP/Postal Code: PostalCode 2 > Null;Country: Country 2 > Null;Description: Description > Null;Type: Postal (postal) > Null;co_person_role: 2 (2) >  ', '2022-06-22 22:03:55', '2022-06-22 22:03:55', NULL, 0, 'FALSE', 'co_1.api-user')
       
      2022-06-22T22:03:55.498041345Z 2022-06-22 22:03:55.497 UTC [183] ERROR:  insert or update on table "cm_history_records" violates foreign key constraint "cm_history_records_co_service_id_fkey"
       
      2022-06-22T22:03:55.498060678Z 2022-06-22 22:03:55.497 UTC [183] DETAIL:  Key (co_service_id)=(1) is not present in table "cm_co_services".

      Here is the cm_history_records table definition :

      registry=# \d cm_history_records
                                                  Table "public.cm_history_records"
             Column       |            Type             | Collation | Nullable |                    Default                     
      --------------------+-----------------------------+-----------+----------+------------------------------------------------
       id                 | integer                     |           | not null | nextval('cm_history_records_id_seq'::regclass)
       co_person_id       | integer                     |           |          | 
       co_person_role_id  | integer                     |           |          | 
       org_identity_id    | integer                     |           |          | 
       co_group_id        | integer                     |           |          | 
       co_email_list_id   | integer                     |           |          | 
       co_service_id      | integer                     |           |          | 
       actor_co_person_id | integer                     |           |          | 
       actor_api_user_id  | integer                     |           |          | 
       action             | character varying(4)        |           |          | 
       comment            | character varying(256)      |           |          | 
       created            | timestamp without time zone |           |          | 
       modified           | timestamp without time zone |           |          | 
       history_record_id  | integer                     |           |          | 
       revision           | integer                     |           |          | 
       deleted            | boolean                     |           |          | 
       actor_identifier   | character varying(256)      |           |          | 
      Indexes:
          "cm_history_records_pkey" PRIMARY KEY, btree (id)
          "cm_history_records_i1" btree (co_person_id)
          "cm_history_records_i2" btree (co_person_role_id)
          "cm_history_records_i3" btree (org_identity_id)
          "cm_history_records_i4" btree (co_group_id)
          "cm_history_records_i5" btree (history_record_id)
          "cm_history_records_i6" btree (co_email_list_id)
      Foreign-key constraints:
          "cm_history_records_actor_api_user_id_fkey" FOREIGN KEY (actor_api_user_id) REFERENCES cm_api_users(id)
          "cm_history_records_actor_co_person_id_fkey" FOREIGN KEY (actor_co_person_id) REFERENCES cm_co_people(id)
          "cm_history_records_co_email_list_id_fkey" FOREIGN KEY (co_email_list_id) REFERENCES cm_co_email_lists(id)
          "cm_history_records_co_group_id_fkey" FOREIGN KEY (co_group_id) REFERENCES cm_co_groups(id)
          "cm_history_records_co_person_id_fkey" FOREIGN KEY (co_person_id) REFERENCES cm_co_people(id)
          "cm_history_records_co_person_role_id_fkey" FOREIGN KEY (co_person_role_id) REFERENCES cm_co_person_roles(id)
          "cm_history_records_co_service_id_fkey" FOREIGN KEY (co_service_id) REFERENCES cm_co_services(id)
          "cm_history_records_history_record_id_fkey" FOREIGN KEY (history_record_id) REFERENCES cm_history_records(id)
          "cm_history_records_org_identity_id_fkey" FOREIGN KEY (org_identity_id) REFERENCES cm_org_identities(id)
      Referenced by:
          TABLE "cm_history_records" CONSTRAINT "cm_history_records_history_record_id_fkey" FOREIGN KEY (history_record_id) REFERENCES cm_history_records(id)

      Attachments

        Activity

          People

            tom.zeller.5@at.internet2.edu Tom Zeller
            tom.zeller.5@at.internet2.edu Tom Zeller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: