Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Contribution]: Better to throw exception when future datetime is specified to endpoints for current/historical data #396

Open
2 tasks done
YaSuenag opened this issue Sep 19, 2023 · 8 comments
Assignees
Labels
for discussion Tabled for discussion in weekly team call vNext

Comments

@YaSuenag
Copy link
Contributor

What happened?

We would receive HTTP 204 (No content) when we pass future datetime to endpoints of current/historical data (e.g. /emissions/bylocation) in WebAPI. However these endpoints would not handle forecast data, so future datetime as parameters are not expected.

We've discussed about this whether it would be better to throw exception (e.g. ArgumentOutOfRangeException) in this case in #389 and #384. If throwing exception is appropriate, we need to fix all of datasources (WattTime, ElectricityMaps, ElectricityMapsFree, JSON).

Code of Conduct

  • I agree to follow this project's Code of Conduct

Feature Commitment

  • I commit to contributing this feature as a PR and working with the GSF to merge this feature into the Carbon Aware SDK.
@Willmish
Copy link
Collaborator

I have mixed opinions on this, so will share both reasons why I think we might want it and why not.
Why we SHOULD throw an exception:

  • we can catch the exception higher up and return a 400 error on invalid time range in the endpoints. This immediately gives feedback to the user that there cannot be any valid values returned for that time range. (if not already covered, we can then also return this when startDate is later than endDate)

Why we SHOULDN'T throw an exception:

  • if we preprocess the time range to determine whether to throw an exception or not, we need to make assumptions on ALL underlying data sources, that this time range is invalid. And although for WattTime, EM and EMfree this seems to make sense at the moment, maybe we need to keep in mind future datasources which might accept time ranges for future dates on historical endpoints. This can be disregarded however, if we never want to allow forecast data to be returned from a historical endpoint (which does make sense).

Additionally, when implementing this we need to think in which timezone and at what times the cutoff time for most recent emission is - e.g. if EMFree has a few hour delay, then requesting current time emissions might be invalid, as the most recent emission is from few hours ago.

@YaSuenag
Copy link
Contributor Author

maybe we need to keep in mind future datasources which might accept time ranges for future dates on historical endpoints. This can be disregarded however, if we never want to allow forecast data to be returned from a historical endpoint (which does make sense).

I think we can disallow historical endpoint never accept request for forecasting because it is for "historical".

Additionally, when implementing this we need to think in which timezone and at what times the cutoff time for most recent emission is - e.g. if EMFree has a few hour delay, then requesting current time emissions might be invalid, as the most recent emission is from few hours ago.

I've raised this issue about passing future datetime to historical endpoint, so I think we don't need to think about this case.
But I think we can following cases:

  1. do not specify time range:
    • SDK can return current emission data because time range does not specified.
  2. start time is specified, and emission data in range is available
    • SDK can return emission data.
  3. start time is specified, but emission data is out of range
    • SDK cannot return emission data.
  4. start time points the future
    • SDK should not return (should throw exception) on historical endpoint.

I think your concern fits case 2 and 3, it means the SDK user specifies start datetime, so I think it can be allowed that the SDK would not return any data when emission data is out of specified time range.

@vaughanknight
Copy link
Contributor

vaughanknight commented Oct 17, 2023

Can we please create an ADR for this as per the meeting last week on the 2023-10-10 #402 . Thanks!

Copy link
Contributor

This issue has not had any activity in 120 days. Please review this issue and ensure it is still relevant. If no more activity is detected on this issue for the next 20 days, it will be closed automatically.

@github-actions github-actions bot added the stale label Feb 15, 2024
@YaSuenag
Copy link
Contributor Author

Wait, do not close this issue.

I will start to work when I can (maybe after clarifying vNext)

@danuw
Copy link
Collaborator

danuw commented Mar 12, 2024

What is next on this one please?

Copy link
Contributor

This issue has not had any activity in 120 days. Please review this issue and ensure it is still relevant. If no more activity is detected on this issue for the next 20 days, it will be closed automatically.

@github-actions github-actions bot added the stale label Jul 11, 2024
@YaSuenag
Copy link
Contributor Author

Please remove stale label from this issue.

Priority of this issue is not high, but it is worth to discuss I think. I'll back when other issues/PRs are closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for discussion Tabled for discussion in weekly team call vNext
Projects
None yet
Development

No branches or pull requests

4 participants