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

Fixes to INI parsing incomplete #2363

Closed
gdavison opened this issue Nov 9, 2023 · 2 comments · Fixed by #2365
Closed

Fixes to INI parsing incomplete #2363

gdavison opened this issue Nov 9, 2023 · 2 comments · Fixed by #2365
Assignees
Labels
bug This issue is a bug. p1 This is a high priority issue

Comments

@gdavison
Copy link
Contributor

gdavison commented Nov 9, 2023

Describe the bug

The PR #2359 fixes some parsing issues with INI files introduced in github.com/aws/aws-sdk-go-v2/internal/ini v1.5. However, the following errors still occur

  1. Leading newline plus leading whitespace
	[default]
	region = us-west-2

This will fail to parse silently. The initial token returned by lexer.Tokenize is a TokenLit with the value "\n\t[default]\n\tregion = us-west-2"

  1. Subsequent profile is indented
[default]
region = us-west-2

	[profile example]
	region = us-east-1

This will fail to parse silently, but return a config.SharedConfigProfileNotExistError. The corresponding token returned by lexer.Tokenize is a TokenLit with the value "\n\t[profile test]\n\tregion = us-east-1"

Expected Behavior

Both cases should return parsing errors

Current Behavior

Parsing fails silently. In the second case, it returns config.SharedConfigProfileNotExistError instead of a parsing error.

Reproduction Steps

Run tests using the sample INI files above

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2/config@3db3b148a440
github.com/aws/aws-sdk-go-v2/internal/ini@3db3b148a440

Compiler and Version used

go version go1.21.0 darwin/arm64

Operating System and version

macOS 13.4.1

@gdavison gdavison added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2023
@lucix-aws lucix-aws linked a pull request Nov 10, 2023 that will close this issue
@lucix-aws
Copy link
Contributor

lucix-aws commented Nov 10, 2023

@gdavison Thanks for the continued engagement on this. At this point I am convinced we need to move forward with an overhaul of the parsing implementation in general.

To provide some context - the implementor of the existing parser is no longer on the project, and with a more or less complete lack of documentation all institutional knowledge of this implementation was lost. At the time of adding support for endpoint URL config, the implementing SDE and myself determined that the "syntax tree" could not be reasonably extended to handle sub-property support required for the feature. We instead chose to handle this at the tokenize stage which has clearly introduced a handful of nasty regressions as you've observed.

To wit I've nuked the old implementation and introduced a greatly simplified line-based version in #2365. The main benefit of the new implementation is to get rid of the frankly asinine behavior of silently dropping entire sections on parse failures, instead we will simply ignore lines that appear in an invalid context and move on.

I've also made the decision to allow leading whitespace in profile declarations, basically the goal being to never risk dropping an otherwise valid section of properties if we can avoid it. This is technically a behavioral break (e.g. property continuation lines that matched profile declaration syntax will instead now be recognized as profiles) but I believe it's the most sensible way forward here.

The behavioral change of not supporting leading whitespace in properties will have to remain EDIT: it actually won't. I've made a change to handle these in context, if a property with leading whitespace (which we'll tokenize as a sub-property) is either at the beginning of a section or the key that precedes it isn't empty, we'll just treat it as a regular property. This combined with allowing leading whitespace on profiles should restore us to a state equivalent to what we were in before last week's change.

@lucix-aws lucix-aws self-assigned this Nov 10, 2023
@RanVaknin RanVaknin added p1 This is a high priority issue queued This issues is on the AWS team's backlog and removed needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@lucix-aws lucix-aws removed the queued This issues is on the AWS team's backlog label Nov 13, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1 This is a high priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants