Skip to content

add failing test for issue 777 #782

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

Closed
wants to merge 4 commits into from
Closed

Conversation

jrushlow
Copy link
Collaborator

@jrushlow jrushlow commented Jan 11, 2021

WIP
fixes #777

@jrushlow jrushlow added the Status: Needs Work Additional work is needed label Jan 11, 2021
@@ -0,0 +1,14 @@
caddy:
ports:
- "80:80"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For purposes of figuring out the root cause, if you changed this from "80:80" to "foo_bar", does the error happen?

Or, if you use '80:80' with single quotes - error or no?

volumes:
- caddy_data
===
$data['caddy']['ports'][] = "443:443";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again for purposes of figuring out the root cause, if you changed this from "443:443" to "foo_bar", does the error happen?

caddy:
ports:
- "foo:foo"
- 'bar:baz'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes. but not w/ "80:80"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't change the existing double quotes to single quotes. It's only that the NEW keys we add are double quotes? If so, I think it's fine.

@jrushlow
Copy link
Collaborator Author

jrushlow commented Feb 16, 2021

Partial YSM: Debug for case array_double_quoted_80_value_single.test with "80:80" in place of "foo:foo"

...
START key
            key: ports
          depth: 1
       position: 6
    indentation: 0
           type: hash
         format: multi
        content: >\r\n    ports:\r\n      - "80:80"\r\n    volumes:\r\n     <

Advancing position beyond key "ports"
            key: ports
          depth: 1
       position: 6
    indentation: 0
           type: hash
         format: multi

advanceCurrentPosition() from 6 to 18
            key: ports
          depth: 1
       position: 6
    indentation: 0
           type: hash
         format: multi
        content: >\r\n    ports:\r\n      - "80:80"\r\n    volumes:\r\n     <

Calculating new indentation: changing from 0 to 4
            key: ports
          depth: 1
       position: 18
    indentation: 0
           type: hash
         format: multi
        content: >\r\n      - "80:80"\r\n    volumes:\r\n      - caddy_dat<

Calling updateData() on next level
            key: ports
          depth: 1
       position: 18
    indentation: 4
           type: hash
         format: multi

Changing array type & format via updateData() (type=sequence, format=multi)
            key: n/a
          depth: 2
       position: 19
    indentation: 4
           type: sequence
         format: multi

Advancing position beyond PREV key
            key: 0
          depth: 2
       position: 19
    indentation: 4
           type: sequence
         format: multi

advanceCurrentPosition() from 19 to 30
            key: 0
          depth: 2
       position: 19
    indentation: 4
           type: sequence
         format: multi
        content: >\n      - "80:80"\r\n    volumes:\r\n      - caddy_data<

Calculating new indentation: changing from 4 to 6
            key: 0
          depth: 2
       position: 30
    indentation: 4
           type: sequence
         format: multi
        content: >0:80"\r\n    volumes:\r\n      - caddy_data<

START key
            key: 0
          depth: 2
       position: 30
    indentation: 6
           type: sequence
         format: multi
        content: >0:80"\r\n    volumes:\r\n      - caddy_data<

Advancing position beyond key "0"
            key: 0
          depth: 2
       position: 30
    indentation: 6
           type: sequence
         format: multi

advanceCurrentPosition() from 30 to 32
            key: 0
          depth: 2
       position: 30
    indentation: 6
           type: sequence
         format: multi
        content: >0:80"\r\n    volumes:\r\n      - caddy_data<

Calculating new indentation: changing from 6 to 6
            key: 0
          depth: 2
       position: 32
    indentation: 6
           type: sequence
         format: multi
        content: >80"\r\n    volumes:\r\n      - caddy_data<

value did not change
            key: 0
          depth: 2
       position: 32
    indentation: 6
           type: sequence
         format: multi

Advancing position beyond value "80:80"
            key: 0
          depth: 2
       position: 32
    indentation: 6
           type: sequence
         format: multi

@jrushlow
Copy link
Collaborator Author

Part of the problem is in

preg_match($this->getKeyRegex($key), $this->contents, $matches, \PREG_OFFSET_CAPTURE, $this->currentPosition);

$key = 0;

$regex = $this->getKeyRegex($key);

var_dump($regex);  // `0( )*:`

which hits on the first 0 of the value "80:80"

@jrushlow
Copy link
Collaborator Author

jrushlow commented Feb 16, 2021

The second part of the problem - When you set a value - "bar:baz"

Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'caddy:
     ports:
       - "80:80"
-      - "bar:baz"
+      - 'bar:baz'
     volumes:
       - caddy_data'

which is caused by Update: YSM does not preserve quotes on array values. So - 'foo' or - "foo" are both passed as foo within YSM - not 'foo' or "foo"

$newDataString = Yaml::dump($data, 4, $indent);

`
image

@jrushlow
Copy link
Collaborator Author

fix for this was provided in #816 & #818

@jrushlow jrushlow closed this Feb 18, 2021
@jrushlow jrushlow deleted the fix/777 branch March 3, 2021 14:20
@jrushlow jrushlow added the Minor Minor Enhancement label May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minor Minor Enhancement Status: Needs Work Additional work is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docker][database] the maker does not work because of the YamlSourceManipulator
2 participants