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

The scan API does not properly handle newline characters in windows OS #4330

Closed
madhukaw opened this issue Apr 11, 2023 · 3 comments · Fixed by ballerina-platform/module-ballerina-yaml#43
Labels
module/yaml Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug

Comments

@madhukaw
Copy link
Contributor

Description:

$Subject

This is because the check here[1] becomes false in windows, but in ubuntu, it becomes true and works as expected.

Steps to reproduce:

Run this test case in windows:

@test:Config {
    groups: ["api"]
}
function testReadTOMLString() returns error? {
    string input = string `
        outer:
          inner: {outer: inner}
        seq:
          - - [[nested, sequence]]
        int: 1
        bool: true
        float: 1.1`;
    json output = check readString(input);

    test:assertEquals(output, {
        "outer": {
            "inner": {
                "outer": "inner"
            }
        },
        "seq": [[[["nested", "sequence"]]]],
        "int": 1,
        "bool": true,
        "float": <decimal>1.1
    });
}

Output:

Invalid character '
' for a '<yaml-document>'.

Affected Versions:
0.1.0

OS, DB, other environment details and versions:
Windows

[1] https://github.com/ballerina-platform/module-ballerina-yaml/blob/b6356efb53513341bc831fa02130867b41f63df5/modules/lexer/lexer.bal#L66

@madhukaw madhukaw added Type/Bug module/yaml Team/PCM Protocol connector packages related issues labels Apr 11, 2023
@madhukaw madhukaw changed the title The scan API does not properly handle newlines in windows OS The scan API does not properly handle newline characters in windows OS Apr 11, 2023
@SasinduDilshara
Copy link
Contributor

SasinduDilshara commented Apr 11, 2023

Imo, this issue is occurred because windows read new line as \r\n and ubuntu take new line as \n.

Above if checks only checks the ubuntu case, those are not check the windows case.

To resolve this we need to update lexer to handle \r\n and update above if cases to handle \r\n.

@nipunayf
Copy link

Currently, there is no API to determine the running OS during runtime in Ballerina. Waiting for an API as tracked here: #4931 to resolve this issue.

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@nipunayf nipunayf added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/yaml Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants