Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release::releases::get_logs() returns unprintable/garbled string #74

Open
johnbatty opened this issue Oct 7, 2022 · 3 comments
Open

Comments

@johnbatty
Copy link
Collaborator

johnbatty commented Oct 7, 2022

release::releases::get_logs() is currently defined to return Result<String>. However, it currently returns a lot of unprintable/garbled data...

Inspection of the response headers shows that the data is in compressed format:

content-type: application/zip; api-version=7.1-preview.2

Need to decide whether this API function should:

  • Auto-decompress the data, by inspecting the content-type header and doing unzip before returning the data as Result<String>
  • Document the fact that the returned data is zipped, and change the return type to be raw data: Result<Vec<u8>>, leaving it up to the application to decompress (if required - app might just want to write the logs as a compressed file...)

I expect that this might apply to other API functions too.

@johnbatty
Copy link
Collaborator Author

The python client explicitly sets accept_media_type='application/zip' on the request, and returns a stream_download(...), which seems to imply that it is not decompressing the data, but just streaming the raw body data.
https://github.com/microsoft/azure-devops-python-api/blob/dev/azure-devops/azure/devops/v6_0/release/release_client.py#L499
https://learn.microsoft.com/en-us/python/api/msrest/msrest.service_client.ServiceClient?view=azure-python#msrest-service-client-serviceclient-stream-download

@johnbatty
Copy link
Collaborator Author

johnbatty commented Oct 7, 2022

Worth noting that the OpenAPI spec does state that the request produces application/zip, and that the response is type String, format Stream (which is not a valid OpenAPI schema format...). Should probably be declared as "type: string, format: binary"

    "/{organization}/{project}/_apis/release/releases/{releaseId}/logs": {
      "get": {
...
        "description": "Get logs for a release Id.",
        "operationId": "Releases_Get Logs",
        "produces": [
          "application/zip"
        ],
...
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "type": "string",
              "format": "Stream"
            }
          }
        },

@johnbatty
Copy link
Collaborator Author

Added an example release_logs that shows how to extract and save the compressed data as a zip file via raw_response().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant