Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"project-job trace" print nothing #548

Copy link
Copy link
@liaoya

Description

@liaoya
Issue body actions

Description of the problem, including code/CLI snippet

Gitlab API provide trace endpoint for job (https://docs.gitlab.com/ee/api/jobs.html). I find I run gitlab project-job trace --project-id 5623 --id 872795 and nothing return. But when I run curl -X GET -sL --header "PRIVATE-TOKEN: xxxxxx" "https://xxx.xxxx.com/api/v4/projects/5623/jobs/872795/trace", I can find the output

Expected Behavior

gitlab project-job trace should output the trace

Actual Behavior

gitlab project-job trace does not show the trace

Specifications

  • python-gitlab version: 1.5.11
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): {"version":"10.6.3","revision":"753d851"}

Some investigation

I dig the code and find the root cause, gitlab.v4.cli.run method only handle four type and has no else statement.

def run(gl, what, action, args, verbose, output, fields):
    g_cli = GitlabCLI(gl, what, action, args)
    data = g_cli()

    printer = PRINTERS[output]()

    if isinstance(data, dict):
        printer.display(data, verbose=True, obj=data)
    elif isinstance(data, list):
        printer.display_list(data, fields, verbose=verbose)
    elif isinstance(data, gitlab.base.RESTObject):
        printer.display(get_dict(data, fields), verbose=verbose, obj=data)
    elif isinstance(data, six.string_types):
        print(data)

But ProjectJob.trace() return bytes (<class 'bytes'>), so there is no operation. project-job trace is a little special, it does not return a file downloadable or a json string as most of gitlab API does.

As requests.Response.content is bytes and requests.Response.text is unicode, I personal fix is replacing return utils.response_content(result, streamed, action, chunk_size) with return result.text for gitlab.v4.object.ProjectJob.trae()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.