Skip to content

Missing PR number in CiVisibilityRepoServices implementation #9295

Closed

Description

@mlschechter

Tracer Version(s)

1.51.2~d5ad1fed74

Java Version(s)

11

JVM Vendor

Eclipse Adoptium / Temurin

Bug Report

In our test executions when test optimization is enabled, we see the following log output:

[dd.trace 2025-08-01 15:44:35:190 +0000] [main] INFO datadog.trace.civisibility.CiVisibilityRepoServices - PR detected: PR{baseBranch='master', baseSHA='<BASE_SHA>', commitSHA='<COMMIT_SHA>', prNumber='null'}

We are using the test optimization GitHub Action as follows in our workflow on our GitHub Enterprise Server instance:

      - name: 'Configure Datadog Test Optimization'
        uses: datadog/test-visibility-github-action@v2
        with: { languages: 'java', api_key: '<DD_API_KEY>', service: 'service-name-here' }

Expected Behavior

It is expected that when running tests against a pull request, the PR metadata will be obtained from the Git provider and populated with all available data. In this case, the PR number is available (as demonstrated in the GithubActionsInfo implementation), so our expectation is that CiVisibilityRepoServices would obtain and use the same information. It appears an instance of CIProviderInfo is available in the execution context for use.

Reproduction Code

The code in CiVisibilityRepoServices explicitly sets the prNumber field to null via the PullRequestInfo constructor.

Activity

  1. nikita-tkachenko-datadog commented on Aug 1, 2025

    @nikita-tkachenko-datadog
    Contributor

    Hi @mlschechter, thank you for reporting this issue. It is addressed in #9210 that will be released with v1.52.0 scheduled for the 4th of August

  2. mlschechter commented on Aug 1, 2025

    @mlschechter
    Author

    @nikita-tkachenko-datadog - Thanks for the quick response!

    I'm a bit confused as to how that PR (which was merged to master) will fix the issue, as I am seeing the explicit null assignment in the code there.

    Is there something I'm missing?

  3. nikita-tkachenko-datadog commented on Aug 1, 2025

    @nikita-tkachenko-datadog
    Contributor

    The buildUserPullRequestInfo method creates PR info from environment variables that are manually set by the users (DD_GIT_PULL_REQUEST_BASE_BRANCH and DD_GIT_PULL_REQUEST_BASE_BRACH_SHA). This is a workaround for the CI providers where PR info cannot be extracted automatically. We do not support manually providing PR number (although we probably should), hence the explicit null assignment in that method.

    The caller of this method -buildPullRequestInfo - also calls ciProviderInfo.buildPullRequestInfo() to get PR information supplied by the CI provider. The results of the two calls are merged, with the manually provided info having higher priority.

    The relevant change in the PR is done in the GithubActionsInfo class:

    Double number = (Double) pullRequest.get("number");
    if (number != null) {
      prNumber = String.valueOf(number.intValue());
    }
    
  4. mlschechter commented on Aug 1, 2025

    @mlschechter
    Author

    Got it - thanks for the clarification!

    If I'm following correctly, that change is used here, and will overwrite the explicit null I found in the earlier generation of userInfo.

    Please let me know if I should close this issue out.

  5. nikita-tkachenko-datadog commented on Aug 4, 2025

    @nikita-tkachenko-datadog
    Contributor

    Exactly, your understanding is correct!
    I will go ahead and close the issue, feel free to reopen if the upcoming release doesn't fix it

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions