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

Tabs in strings renders non-obvious error message #6068

Closed
anderseknert opened this issue Jun 30, 2023 · 4 comments
Closed

Tabs in strings renders non-obvious error message #6068

anderseknert opened this issue Jun 30, 2023 · 4 comments

Comments

@anderseknert
Copy link
Member

Placing an actual tab character (and not \t) in a regular string results in a non-obvious and hard to debug error message.

foo := "	foo"
1 error occurred: policy.rego:3: rego_parse_error: unexpected assign token: expected rule value term (e.g., foo := <VALUE> { ... })
	foo := "	foo"
	    ^

Whether this should be allowed or not, I don't know. But it's obviously not the assign token that's an issue here, so if this should be an error it should at least be reported accurately.

What does work:

foo := "\tfoo"
foo := `	foo`
@srenatus
Copy link
Contributor

srenatus commented Jun 30, 2023

Another variant of this, I suppose: #1129 -- No wait, it's not. Ignore me 😅 Well, maybe a bit.

@anderseknert
Copy link
Member Author

🙂 Yeah, somewhat related!

Further research says that the tab character must be escaped as else it would not be a valid JSON value. So it's correct to flag this as an error. The error message should say something like "illegal tab character in string — use escape character \t instead".

@stale
Copy link

stale bot commented Jul 30, 2023

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

@stale stale bot added the inactive label Jul 30, 2023
@anderseknert
Copy link
Member Author

This is a side effect of #6563, but I had no idea about that when I created this issue. Closing this, but hoping that the main issue is prioritized soon as it's making our error messages useless in so many places where they shouldn't be.

Replacing the := with = in the first example will have OPA return an error message relevant to the error.

2 errors occurred:
policy.rego:5: rego_parse_error: illegal string literal: "	foo"
	foo = "	foo"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants