Skip to content

Conversation

@nora-shap
Copy link
Member

Description

True Tokenless is coming. For it to work, it needs git_service. Removing this conditional allows git_service to be included on more uploads so they will be eligible for TT.

Copy link

@codecov codecov bot left a comment

Choose a reason for hiding this comment

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

The overall changes made in the diff seem to create a looser check for an 'uploadToken'. It is removing an additional condition of 'branch' breakdown. However, without context, it's not sure why this change is needed. In particular, the presence or absence of 'uploadToken' does not seem to be correlated with the 'gitService'. If there's a correlation, the 'gitService' should not be set if 'uploadToken' is set, or vice versa.

* See: https://github.com/codecov/codecov-api/pull/741
*/
if (!uploadToken && serviceParams.branch?.includes(":")) {
if (!uploadToken) {
Copy link

Choose a reason for hiding this comment

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

This check now only verifies the existence of an 'uploadToken'. It will enter the if block even if there is no ':' in the 'branch'. Consider rechecking the requirements for 'uploadToken' and 'branch'.

*/
if (!uploadToken && serviceParams.branch?.includes(":")) {
if (!uploadToken) {
if (gitService) {
Copy link

Choose a reason for hiding this comment

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

Here you are setting 'gitService' if 'uploadToken' is not available. The control flow suggests that these two fields are somehow interchangeable or correlated. However, there might not be any correlation between 'uploadToken' and 'gitService', consider segregating the conditions or explain the logical correlation between them.

@codecov
Copy link

codecov bot commented Oct 12, 2024

❌ 11 Tests Failed:

Tests completed Failed Passed Skipped
308 11 297 0
View the top 3 failed tests by shortest run time
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > unsuccessful request > returned data is undefined > throws an error
Stack Traces | 0.001s run time
AssertionError: expected Error: No upload token provided to be an instance of FailedFetchError
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:396:23
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > unsuccessful request > using oidc and not github actions > throws an error
Stack Traces | 0.001s run time
AssertionError: expected Error: No upload token provided to be an instance of BadOIDCServiceError
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:488:23
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > successful request > when the initial response is successful > "uploadToken" is not provided > user provides "gitService" > returns the pre-signed URL with the passed"git_service" in the request body
Stack Traces | 0.002s run time
Error: No upload token provided
 ❯ Module.getPreSignedURL src/utils/getPreSignedURL.ts:91:11
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:182:31

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@codecov-staging
Copy link

codecov-staging bot commented Oct 12, 2024

❌ 11 Tests Failed:

Tests completed Failed Passed Skipped
308 11 297 0
View the top 3 failed tests by shortest run time
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > unsuccessful request > returned data is undefined > throws an error
Stack Traces | 0.001s run time
AssertionError: expected Error: No upload token provided to be an instance of FailedFetchError
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:396:23
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > unsuccessful request > using oidc and not github actions > throws an error
Stack Traces | 0.001s run time
AssertionError: expected Error: No upload token provided to be an instance of BadOIDCServiceError
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:488:23
src/utils/__tests__/getPreSignedURL.test.ts getPreSignedURL > unsuccessful request > fetch throws an error > throws an error
Stack Traces | 0.002s run time
AssertionError: expected Error: No upload token provided to be an instance of FailedFetchError
 ❯ .../utils/__tests__/getPreSignedURL.test.ts:458:23

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

@codecov codecov bot left a comment

Choose a reason for hiding this comment

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

CodecovAI submitted a new review for 0a89a12

* proper tokenless upload.
* See: https://github.com/codecov/codecov-api/pull/741
*/
if (!uploadToken && serviceParams.branch?.includes(":")) {
Copy link

Choose a reason for hiding this comment

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

Removing this condition means the format of the branch is no longer checked. Has the branch check been moved elsewhere, or is it no longer needed? If not necessary anymore, kindly disregard the comment.

const foundGitService = findGitService();
if (!foundGitService || foundGitService === "") {

if (gitService) {
Copy link

Choose a reason for hiding this comment

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

This gitService check is used to set the requestBody.git_service. However, what happens when the gitService isn't provided or found? Ensure fallback or error handling measures are in place.

if (gitService) {
requestBody.git_service = gitService;
} else {
const foundGitService = findGitService();
Copy link

Choose a reason for hiding this comment

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

The findGitService function is called here if gitService is not provided. This is good since it provides a fallback for gitService.

requestBody.git_service = gitService;
} else {
const foundGitService = findGitService();
if (!foundGitService || foundGitService === "" && !uploadToken) {
Copy link

Choose a reason for hiding this comment

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

This condition checks again if gitService exists. However, aren't we already in a code block where we know gitService doesn't exist? This check seems redundant and may lead to unnecessary computational costs.

}
} else if (oidc?.useGitHubOIDC && Core) {
}
if (oidc?.useGitHubOIDC && Core) {
Copy link

Choose a reason for hiding this comment

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

The condition 'oidc?.useGitHubOIDC && Core' is left unchanged but with updated indentation level. This alteration shows good git practice. However, its purpose isn't clear without context, make sure 'Core' is defined somewhere above the code block. If 'Core' is not defined elsewhere, there will be a reference error at runtime.

@nicholas-codecov
Copy link

@nora-codecov is this PR still active or are we good to close in favour of #189 ?

@nora-shap nora-shap closed this Nov 14, 2024
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.

3 participants