Skip to content

ProjectFileManager does not implement head method to meet API spec #2976

Description

@holysoles

Description of the problem, including code/CLI snippet

Attempting to use a HEAD request to retrieve file metadata from a project repository (Gitlab REST API docs) fails with a 404

dest_file_get_args = {
  'file_path': file_def['dest_filepath'],
  'ref': 'HEAD',
}
existing_file = project.files.head(**dest_file_get_args)

Expected Behavior

Should return 200 and file metadata. The same request as a GET request returns 200, and they follow the same URL path and parameter requirements. Sending a GET request logs this URL path:

DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/1/repository/files/somefile.txt?ref=HEAD HTTP/11" 200 418

Actual Behavior

A HTTP HEAD request is sent with the following URL path:
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "HEAD /api/v4/projects/1/repository/files?file_path=somefile.txt&ref=HEAD HTTP/11" 404 0

Specifications

  • python-gitlab version: 3.1.43 4.9.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): v16.7.4-ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions