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

Avoid Early Convert ret['comment'] to String #37424

Merged

Conversation

kojiromike
Copy link
Contributor

What does this PR do?

Fixes this exception:

Traceback (most recent call last):
  File "/var/tmp/.syops_b1274f_salt/py2/salt/state.py", line 1733, in call
    **cdata['kwargs'])
  File "/var/tmp/.syops_b1274f_salt/py2/salt/loader.py", line 1652, in wrapper
    return f(*args, **kwargs)
  File "/var/tmp/.syops_b1274f_salt/py2/salt/states/gpg.py", line 119, in present
    ret['comment'].append('Adding {0} to GPG keychain'.format(name))
AttributeError: 'str' object has no attribute 'append'

What issues does this PR fix or reference?

The code that mutates the ret['comment'] from a list to a string happens inside a loop. It should happen just before returning.

Previous Behavior

You can only use the gpg.present state with one key at a time, or it will crash.

New Behavior

You can now use the gpg state with multiple keys, as documented.

Tests written?

No

Please review Salt's Contributing Guide for best practices.

Fixes this exception:
An exception occurred in this state: Traceback (most recent call last):
  File "/var/tmp/.syops_b1274f_salt/py2/salt/state.py", line 1733, in call
    **cdata['kwargs'])
  File "/var/tmp/.syops_b1274f_salt/py2/salt/loader.py", line 1652, in wrapper
    return f(*args, **kwargs)
  File "/var/tmp/.syops_b1274f_salt/py2/salt/states/gpg.py", line 119, in present
    ret['comment'].append('Adding {0} to GPG keychain'.format(name))
AttributeError: 'str' object has no attribute 'append'
@kojiromike kojiromike force-pushed the gpg-no-append-method-on-string branch from 790d93b to ceb7735 Compare November 2, 2016 19:50
@cachedout cachedout merged commit cc84356 into saltstack:develop Nov 2, 2016
@cachedout
Copy link
Contributor

Thank you, @kojiromike

@kojiromike kojiromike deleted the gpg-no-append-method-on-string branch November 2, 2016 22:55
@gtmanfred gtmanfred added the bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch label Jul 6, 2017
@rallytime rallytime added ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch. and removed bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch labels Jul 6, 2017
rallytime pushed a commit that referenced this pull request Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZZZ[Done]-back-ported-bf RETIRED The pull request has been back-ported to an older branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants