LibraryOfCongress / api.congress.gov

congress.gov API
601 stars 38 forks source link

(nomination nominees): returns 500 `get() returned more than one NominationPosition -- it returned 2!` #251

Open ryparker opened 4 weeks ago

ryparker commented 4 weeks ago

Requesting the nomination 2691 of the 117th congress return a 500 error:

curl --location 'https://api.congress.gov/v3/nomination/117/2691/1?format=json&limit=250&offset=0&api_key=<API_KEY>'

Response 500:

{
    "error": "get() returned more than one NominationPosition -- it returned 2!\n    query was: (), {\n 'ordinal': '1'} (MultipleObjectsReturned)",
    "request": {
        "congress": "117",
        "contentType": "application/json",
        "format": "json",
        "number": "2691"
    }
}

This also occurred with the following

117th congress:
- nomination 1220, ordinal 1
115th congress:
- nomination 2473, ordinal 1
- nomination 2633, ordinal 1
apreiter18 commented 4 weeks ago

Hi @ryparker - I am doing some digging into these two examples you cited. A few things:

  1. The "/1" at the end of these calls would suggest they are partitioned nominations, which they are not. If you try https://api.congress.gov/v3/nomination/117/1220?format=json&limit=250&offset=0&api_key=INSERTKEY you should get data returned (same for 117 PN 1220).
  2. I think that there is something wrong with the referrer URL in the above calls, though, so I need to submit an investigation ticket here.

Please feel free to report any other items in this Git issue. Thank you!

ryparker commented 4 weeks ago

The "/1" at the end of these calls would suggest they are partitioned nominations, which they are not. If you try api.congress.gov/v3/nomination/117/1220?format=json&limit=250&offset=0&api_key=INSERTKEY you should get data returned (same for 117 PN 1220).

Ah looks like that was an error on my side. Thanks.

ryparker commented 3 weeks ago

Actually this seems to be an error when querying nomination nominees.

Request the details of the nomination:

curl --location 'https://api.congress.gov/v3/nomination/117/2691?api_key=<API_KEY>'

Returns a list of 3 nominees, 2 of them have the same ordinal of 1

{
    "nomination": {
        "actions": {
            "count": 4,
            "url": "https://api.congress.gov/v3/nomination/117/2691/actions?format=json"
        },
        "authorityDate": "2022-12-08",
        "citation": "PN2691",
        "committees": {
            "count": 1,
            "url": "https://api.congress.gov/v3/nomination/117/2691/committees?format=json"
        },
        "congress": 117,
        "isList": true,
        "latestAction": {
            "actionDate": "2022-12-08",
            "text": "Confirmed by the Senate by Voice Vote."
        },
        "nominees": [
            {
                "introText": "THE FOLLOWING NAMED OFFICERS OF THE COAST GUARD PERMANENT COMMISSIONED TEACHING STAFF FOR APPOINTMENT IN THE UNITED STATES COAST GUARD TO THE GRADE INDICATED UNDER TITLE 14, U.S.C., SECTIONS 1944 AND 2126:",
                "nomineeCount": 3,
                "ordinal": 2,
                "organization": "Coast Guard",
                "positionTitle": "Commander",
                "url": "https://api.congress.gov/v3/nomination/117/2691/2?format=json"
            },
            {
                "introText": "THE FOLLOWING NAMED OFFICERS OF THE COAST GUARD PERMANENT COMMISSIONED TEACHING STAFF FOR APPOINTMENT IN THE UNITED STATES COAST GUARD TO THE GRADE INDICATED UNDER TITLE 14, U.S.C., SECTIONS 1944 AND 2126:",
                "nomineeCount": 3,
                "ordinal": 1,
                "organization": "Coast Guard",
                "positionTitle": "COMMANDER",
                "url": "https://api.congress.gov/v3/nomination/117/2691/1?format=json"
            },
            {
                "introText": "THE FOLLOWING NAMED OFFICERS OF THE COAST GUARD PERMANENT COMMISSIONED TEACHING STAFF FOR APPOINTMENT IN THE UNITED STATES COAST GUARD TO THE GRADE INDICATED UNDER TITLE 14, U.S.C., SECTIONS 1944 AND 2126:",
                "nomineeCount": 2,
                "ordinal": 1,
                "organization": "Coast Guard",
                "positionTitle": "Captain",
                "url": "https://api.congress.gov/v3/nomination/117/2691/1?format=json"
            }
        ],
        "number": 2691,
        "partNumber": "00",
        "receivedDate": "2022-10-11",
        "updateDate": "2023-10-13T12:38:59Z"
    },
    "request": {
        "congress": "117",
        "contentType": "application/json",
        "format": "json",
        "number": "2691"
    }
}

Then when you request the duplicated ordinal 1, then the API returns 500:

curl --location 'https://api.congress.gov/v3/nomination/117/2691/1?format=json&limit=250&offset=0&api_key=<API_KEY>'

Response:

{
    "error": "get() returned more than one NominationPosition -- it returned 2!\n    query was: (), {\n 'ordinal': '1'} (MultipleObjectsReturned)",
    "request": {
        "congress": "117",
        "contentType": "application/json",
        "format": "json",
        "number": "2691"
    }
}

Same scenario for 1220, with ordinal 1, in 117th congress