Skip to content

🐛 fix: only fetch public projects and merge requests - #105

Merged
jeanphi-baconnais merged 2 commits into
zenika-open-source:mainfrom
jeanphi-baconnais:fix/fetch-only-public-projects-and-mrs
Nov 3, 2026
Merged

jeanphi-baconnais merged 2 commits into
zenika-open-source:mainfrom
jeanphi-baconnais:fix/fetch-only-public-projects-and-mrs

Conversation

@jeanphi-baconnais

Copy link
Copy Markdown
Member

📝 Description

Ensure that only public projects and merge requests (MRs) from public projects are fetched and counted from GitLab and GitHub.

Previously, when a private access token (gitlab.token) was configured in the environment, the GitLab API returned all accessible projects and MRs, including private ones (such as arbre-gen), skewing member statistics and personal project listings.

🚀 Main Changes

1. GitLab Merge Requests

  • Unauthenticated MR Query (GitLabClient & GitLabServices): Removed the Authorization header param from gitLabClient.getMergeRequests. Querying GET /api/v4/merge_requests?scope=all&author_id=... without authentication guarantees that GitLab returns strictly public MRs, excluding any private projects/MRs accessible via the personal access token.

2. Projects Visibility Filtering

  • GitLab Projects API: Added @QueryParam("visibility") String visibility to gitLabClient.getProjectsForAnUser set to "public" to filter server-side.
  • Model (Project): Added isPrivate (@JsonProperty("private")) and a helper method isPublic() that returns false if private == true or if visibility is private / internal.
  • Services (GitLabServices & GitHubServices): Applied project.isPublic() filtering on personal and organization projects.

3. Personal Projects Synchronization

  • WorkflowRessources: Updated savePersonalProjects() to delete and save GitLab personal projects alongside GitHub personal projects.

4. Testing & Tooling

  • GitLabProjectTest & GitHubProjectTest): Added tests asserting that private projects are identified and rejected by isPublic().
  • GitLabServicesTest: Added tests verifying that private/forked projects are filtered out and that MR counts query without authorization headers.
  • Java 25 Test Setup: Added mock-maker-subclass in src/test/resources/mockito-extensions to ensure Mockito test compatibility with Java 25.

🧪 Verification & Testing

  • Ran mvn test: all 51 tests passed successfully.
  • Verified GitLab API responses to ensure private projects (arbre-gen) and private MRs are excluded from counts.

# Conflicts:
#	src/main/java/fr/zenika/opensource/stats/services/GitLabServices.java
@jeanphi-baconnais
jeanphi-baconnais force-pushed the fix/fetch-only-public-projects-and-mrs branch from 795a05e to 3a0d39d Compare November 3, 2026 08:56
@jeanphi-baconnais
jeanphi-baconnais marked this pull request as ready for review November 3, 2026 12:44
@jeanphi-baconnais
jeanphi-baconnais merged commit fd5628c into zenika-open-source:main Nov 3, 2026
2 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 3, 2026
# [v1.12.1](v1.12.0...v1.12.1) (2026-11-03)

## 🐛 Bug Fixes
- [`fd5628c`](fd5628c)  fix: only fetch public projects and merge requests (#105) (Issues: [`#105`](#105))
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.12.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant