Skip to content

"default" string values containing commas should be respected #4734

Closed

Description

@erikerikson

This is a Bug Report

TL;DR: ${<undefined>,"foo,bar"} should resolve to foo,bar but instead resolves to foo

The following test fails.

    it.only('should properly handle string values containing commas', () => {
      const str = '"foo,bar"'
      const getValueFromSourceStub = sinon.stub(serverless.variables, 'getValueFromSource')
        .resolves(undefined);
      return serverless.variables.overwrite(`opt:stage, ${str}`)
        .should.be.fulfilled
        .then(() => {
          expect(getValueFromSourceStub.getCall(1).args[0]).to.eql(str)
        })
        .finally(() => getValueFromSourceStub.restore());
    });

The result is:

    #overwrite()
      1) should properly handle string values containing commas


  0 passing (104ms)
  1 failing

  1) Variables #overwrite() should properly handle string values containing commas:
      AssertionError: expected '"foo' to equal '"foo,bar"'
      + expected - actual

      -"foo
      +"foo,bar"
      
      at serverless.variables.overwrite.should.be.fulfilled.then.valueToPopulate (lib/classes/Variables.test.js:715:61)
  From previous event:
      at Context.it.only (lib/classes/Variables.test.js:715:10)

Description

For bug reports:

  • What went wrong?
    The variable resolution "overwrite" code splits on commas without respecting the encapsulation of commas by single or double quotes.

  • What did you expect should have happened?
    It takes the quotes into account and resolves ${opt:stage,"foo,bar"} to foo,bar.

Additional Data

  • Serverless Framework Version you're using: master
  • Operating System: osx
  • Stack Trace: n/a
  • Provider Error messages: n/a

Activity

  1. erikerikson commented on Feb 8, 2018

    @erikerikson
    ContributorAuthor

    ^ edit: less stupid test

  2. added a commit that references this issue on Feb 17, 2018
  3. added a commit that references this issue on Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions