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

[pkg/ottl] Improve Time converter error messages #35176

Open
edmocosta opened this issue Sep 13, 2024 · 1 comment
Open

[pkg/ottl] Improve Time converter error messages #35176

edmocosta opened this issue Sep 13, 2024 · 1 comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium

Comments

@edmocosta
Copy link
Contributor

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

The Time converter errors messages currently refer to the Go's layout elements instead of the ctime-like substitutes. It might be confusing for users not familiar with the Go layout and/or non-developers.

For example, when converter Time(attributes["time.attribute"], "%B %g %A, %Y, %r") receives the value Invalid 25 Thursday, 1993, 02:03:04 pm , it results into the following error:

parsing time "Invalid 25 Thursday, 1993, 02:03:04 pm" as "January 2 Monday, 2006, 03:04:05 pm": cannot parse "Invalid 25 Thursday, 1993, 02:03:04 pm" as "January"

IMO, there's no clear relation between the Time configured format and the error message details.

Describe the solution you'd like

Considering the ctime-like directives are first citizens for the Time converter format, reflecting those delimiters on the errors message would be helpful for users. For example, the above error message could be changed to something like:

parsing time "Invalid 25 Thursday, 1993, 02:03:04 pm" as "%B %g %A, %Y, %r": cannot parse "Invalid 25 Thursday, 1993, 02:03:04 pm" as "%B"

The Go's time.ParseError does provide all necessary pieces to build the message like that, so the change could be proxying the standard parse functions errors and provide customised messages.

type ParseError struct {
	Layout     string
	Value      string
	LayoutElem string
	ValueElem  string
	Message    string
}

Describe alternatives you've considered

No response

Additional context

No response

@edmocosta edmocosta added enhancement New feature or request needs triage New item requiring triage labels Sep 13, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium
Projects
None yet
Development

No branches or pull requests

4 participants