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

Added more strict validation on from/until parameters in api #200

Closed
wants to merge 6 commits into from

Conversation

KozzyKoder
Copy link
Contributor

Hello, this PR relates to this issue:
#171

Idea is to find to extend test coverage and find permissive validation rules and restrict them by returning an error instead of default value.

@KozzyKoder KozzyKoder requested a review from grzkv September 10, 2019 12:09
@KozzyKoder
Copy link
Contributor Author

@azhiltsov also some things might be good to think about:

  1. checked how wrong intervals processed at graphite python. Seems it accepts now only from=until, but also until < from. In latter case it looks like it swaps from <-> until. Not intuitive behaviour, is it fine that we restrict this behaviour?

  2. added more restrictions on formats itself:

a) "hh:mm 19940812", "12:30:00 19940812", "12:mm 19940812" - similar inputs with incorrect time now returns an error instead 00:00 in current implementation

b) "-something" - completely incorrect relative times also returns error

c)"17:04 19940812 1001" - more components than required now also results in error

d)"12:30 08-15-06" - date with wrong delimiter returns error

e)"08/15/06 12:30" - swapped date and time also considered as error

f)"+5m" - relative dates in future not allowed also


previously cases described above were returning default value(from - 24hours back, until -now)

What do you think about these cases? Shall we relax some of these restrictions?

@azhiltsov
Copy link
Contributor

azhiltsov commented Sep 11, 2019

Original goal of this project was to implement the same functionality as graphite-web.
We were pursuing this goal for a while by even reproducing some behaviors which might be perceived as buggy.
I do not have strong opinion about behavior we expect from time parsing. The only thing we should cut is ambiguous parameters. If you can easily distinguish 12:30 08-15-06 from 08-15-06 12:30 then I don't see a reason to block this. Grafana for instance performs conversion internally and uses epoch notation, so using extending parsing is mostly targeting human interaction. Most probably graphite-web is using some of human readable notations, and I would call @deniszh to let us know if we are about to brake it.
@gksinghjsr and @grzkv what is your take on this?
I would propose to use "keep what make sense" approach and what does not (but presented in graphite-web) can be opt_in with compatibility config flag.
My vision that carbonapi shouldn't lock-in on whisper as back-end and if so then in some other back-ends queries in the future for instance could make sense.

@grzkv
Copy link
Member

grzkv commented Sep 11, 2019

I don't think we should closely follow python implementation in everything, only in parts where it makes sense. The strong criterion is: Grafana should always work well. As @azhiltsov has described, it uses Unix time so it should be ok.

I think we should drop the behaviour that is confusing or just wrong. Specific examples:

  • until==from does not make any sense
  • until < from is the clearly a user input mistake, treating this as an OK request is very misleading
  • +5m is user input error
  • -something_that_is_not_time is user error

@KozzyKoder To sum, I agree with the points a, b, c, e, f. I think, d is debatable, but I rather agree as well.

date/date.go Outdated Show resolved Hide resolved
@ksurent
Copy link
Contributor

ksurent commented Sep 12, 2019 via email

@grzkv
Copy link
Member

grzkv commented Jan 29, 2020

Hi all. There are a lot of valuable contributions in this PR. How about we move this completion?

@grzkv
Copy link
Member

grzkv commented Aug 17, 2020

@azhiltsov @avereha @grlvrl @KozzyKoder Let's finalize this. We either move on or close.

Taking into account the age and controversy, I suggest we close this.

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.

4 participants