Skip to content

fix: request license information from GitLab API#6593

Open
Anni0506 wants to merge 4 commits into
mindersec:mainfrom
Anni0506:fix/gitlab-license-property
Open

fix: request license information from GitLab API#6593
Anni0506 wants to merge 4 commits into
mindersec:mainfrom
Anni0506:fix/gitlab-license-property

Conversation

@Anni0506

@Anni0506 Anni0506 commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Testing

Summary

This PR fixes an issue where the gitlab/license entity property (RepoPropertyLicense) is always empty for GitLab repositories. The fetch logic in internal/providers/gitlab/repository_properties.go has been updated to correctly pass the ?license=true query parameter required by the GitLab API to include license details in the response.

Fixes #6589

Testing

This is a straightforward API query parameter addition. The underlying gitlab provider package logic handles the mapping once the license payload is retrieved via the modified URL path.

@Anni0506
Anni0506 requested a review from a team as a code owner July 13, 2026 12:23
@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Anni0506

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@intelligent-ears intelligent-ears left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't add any tests verifying that the license field actually gets populated.There can be at least a unit test for gitlabProjectToProperties that confirms license is non-empty when the API response includes a license.

) (*gitlab.Project, error) {
projectURLPath, err := url.JoinPath("projects", url.PathEscape(upstreamID))
projectURLPath = projectURLPath + "?license=true"
if err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?license=true is appended before the error check — the code appends the query param before checking if url.JoinPath returned an error. If JoinPath fails, projectURLPath would be an empty string and the append would produce just ?license=true. The correct order is:

projectURLPath, err := url.JoinPath("projects", url.PathEscape(upstreamID))
if err != nil {
    return nil, fmt.Errorf("failed to join URL path for project using upstream ID: %w", err)
}
projectURLPath = projectURLPath + "?license=true"

@evankanderson

Copy link
Copy Markdown
Member

This PR doesn't add any tests verifying that the license field actually gets populated.There can be at least a unit test for gitlabProjectToProperties that confirms license is non-empty when the API response includes a license.

In particular, we should probably update Test_gitlabClient_FetchAllProperties in properties_test.go to properly emulate the server behavior, and complain / fail the test if the query param is not present.

@coveralls

coveralls commented Jul 14, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 60.935%Anni0506:fix/gitlab-license-property into mindersec:main. No base build found for mindersec:main.

@Anni0506
Anni0506 force-pushed the fix/gitlab-license-property branch from c9a27e7 to dd9935e Compare July 15, 2026 18:56

@evankanderson evankanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests! The test implementation brought up a couple questions (this is the learning process, so it's totally normal to hit these sorts of things).

},
},
{
name: "repository succeeds",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this name to empty-string?

Path: "group",
},
License: &gitlab.ProjectLicense{
Name: "mit", // Changed Key to Name to match repository_properties.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this comment make sense in 6 months?

}


func TestGitlabProjectToProperties_License(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this test cover that the other test doesn't?

In general, extra tests add maintenance burden when refactoring code. That burden pays off when the tests cover additional important code cases, but redundant tests add more maintenance cost without commensurate benefits.

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

Successfully merging this pull request may close these issues.

fix: GitLab project license property always empty due to missing ?license=true parameter

5 participants