microsoft / azure-devops-rust-api

Rust API crate for the Azure DevOps API
MIT License
60 stars 20 forks source link

`azure_devops_rust_api::test::models::IdentityRef` contains a mandatory deprecated `uniqueName` field. #479

Closed mTsBucy1 closed 1 month ago

mTsBucy1 commented 1 month ago

I have run into this problem, while trying to call Test - Points - Get Point and the field LastResultDetails contains a run_by with type azure_devops_rust_api::test::models::IdentityRef. However in this case the server doesn't include the uniqueName or really any metadata.

The example in the api does not even include the LastResultDetails field.

The shortened request/response pair which triggers the error:

GET https://dev.azure.com/<ORG>/<PROJ>/_apis/test/Plans/1/Suites/2/points/1?api-version=7.1-preview'

{
    "id": 1,
    "url": "https://dev.azure.com/<ORG>/<PROJ>/_apis/test/Plans/1/Suites/2/Points/1",
    "assignedTo": {
        "displayName": "<My Name>",
        "url": "<My identiy url>",
        "_links": _,
        "id": "<my uuid>",
        "uniqueName": "<My Mail>",
        "imageUrl": _,
        "descriptor": _
    },
    "lastTestRun": {
        "id": "9",
        "url": "https://dev.azure.com/<ORG>/<PROJ>/_apis/test/Runs/9"
    },
    "lastResult": {
        "id": "100000",
        "url": "https://dev.azure.com/<ORG>/<PROJ>/_apis/test/Runs/9/Results/100000"
    },
    "lastUpdatedDate": "2024-09-11T12:10:04.77Z",
    "lastResetToActive": "2024-09-11T11:08:00.59Z",
    "lastUpdatedBy": {
        "displayName": "<My Name>",
        "url": "<My identiy url>",
        "_links": _,
        "id": "<my uuid>",
        "uniqueName": "<My Mail>",
        "imageUrl": _,
        "descriptor": _
    },
    "testPlan": {
        "id": "1",
        "name": "The Test Plan",
        "url": "https://dev.azure.com/<ORG>/<PROJ>/_apis/test/Plans/1"
    },
    "lastResultDetails": {
        "duration": 0,
        "dateCompleted": "2024-09-11T12:10:04.627Z",
        "runBy": {
            "displayName": "<My Name>",
            "id": "<my uuid>"
            // Here is the problem, the server doesn't give the `uniqueName` here
        }
    },
    ..
}

I wonder what workaround there is. Because making the uniqueName and Option is technically a breaking change, so I don't expect you to do this right away. But then, it is a deprectated field.

Thanks for any help and thanks for maintaining this Wrapper, it is very useful :)

johnbatty commented 1 month ago

Thanks very much for the detailed report. Yes, as you suggest the fix is to make the uniqueName field optional. This is a field within IdentityRef. As you say, this is a breaking change for any existing users, but is the right fix to make. I can document the change and the compiler will tell anyone affected when they upgrade.

mTsBucy1 commented 1 month ago

Okay, nice, yeah I would much appreciate a fix. :) I have now run into this again with another api call.

johnbatty commented 1 month ago

Fixed: https://github.com/microsoft/azure-devops-rust-api/pull/482 I've just published a new version with the fix: 0.22.0.