API endpoint for flag coverage does not properly handle start_date param

Before submitting a topic, please confirm the following

I have searched for similar issues before creating this topic.
I have verified that my repository is using the Codecov GitHub app, if using GitHub
I have validated my codecov.yaml configuration file.
I have filled out the below sections to the best of my ability.

Description

Using Codecov API to retrieve coverage for flags gives incorrect results. The start_date param is not properly handled on the server side, thus I receive the response with the dates preceding the one that I wanted to start with. I am using a YYYY-MM-DD format to return all coverage for each dayfor the last 30 days but the API responds with the coverage starting nearly a year ago.

Documentation about the request I am using: Coverage trend

This is my request:
https://api.codecov.io/api/v2/github/{owner}/repos/{repo}/flags/js/coverage?interval=1d&start_date=2023-01-20&page_size=35

CI/CD URL

Not related.

Codecov Output

Not related

Expected Results

I expect to have the coverage for the provided ‘js’ flag for each day starting from the 30 days ago till today, all in one page. I expect only 30 days time range so it should all fit into one page size (35).

Actual Results

I receive the coverage for the provided flag since May 2022. The response includes 238 results (days), while it should have only 30. Thus, the response is paginated and I need to also add a ‘page’ param to retrieve exactly the data I want.

Additional Information

n/a

@Nojas are you able to provide the actual URL request and payload?

Unfortunately no, because it’s a private repository :frowning_face:
But let me know if I can help any other way.

Got it, is this only with flags or is this happening if you do not have a flag specified?

It happens only for the flag coverage.
When I request:
https://api.codecov.io/api/v2/github/{owner}/repos/{repo}/coverage?interval=1d&start_date=2023-01-20&page_size=35 (same as before, but without /flags/js part), it returns the coverage starting from the date specified in the parameters. So the issue is definitely with the Flags Coverage endpoint.

Ah, got it. Thanks @Nojas, I’ll pass this onto the API team.

@Nojas this should be working now!

It works indeed, thanks @tom!

I see another issue, though. The avg property sometimes has problems with rounding the floating point number, and I get values like:

{
  "timestamp": "2023-02-14T00:00:00Z",
  "min": 34.81607,
  "max": 34.81607,
  "avg": 34.81607000000001
}

in the results for the flag coverage endpoint (https://api.codecov.io/api/v2/github/{owner}/repos/{repo}/coverage).

This makes the results hard to visualize in the charts, because such long values break the axis labels.

Would it be possible to pass it again to the API Team and ask them to properly round the number to a maximum of 5 digits after the comma?

@Nojas I’ll see if there’s anything we can do about that!

@Nojas sorry for the delay here. This should be fixed now! Let me know if you see any other issues.

Correct, it works. Thanks @tom!
Pass my greetings to the Development Team.

1 Like