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

lines in file resource content looking like a checksum throws an error #9412

Open
tmu-sprd opened this issue Jul 9, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@tmu-sprd
Copy link

tmu-sprd commented Jul 9, 2024

Describe the Bug

Using Puppet 8.7.0, issuing this line:
$ puppet apply -e "file { '/tmp/test': ensure => 'file', content => \"# anything\n{abc}$\n# anything\" }"
results in a deprecation warning and error:

$ puppet apply -e "file { '/tmp/test': ensure => 'file', content => \"# anything\n{abc}$\n# anything\" }"
Notice: Compiled catalog for my_machine in environment production in 0.01 seconds
Warning: Using a checksum in a file's "content" property is deprecated. The ability to use a checksum to retrieve content from the filebucket using the "content" property will be removed in a future release. The literal value of the "content" property will be written to the file. The checksum retrieval functionality is being replaced by the use of static catalogs. See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.
   (file: unknown, line: 1)
Error: Could not retrieve content for # anything
{abc}$
# anything from filebucket: Could not get filebucket from file
Error: /Stage[main]/Main/File[/tmp/test]/ensure: change from 'absent' to 'file' failed: Could not retrieve content for # anything
{abc}$
# anything from filebucket: Could not get filebucket from file
Notice: Applied catalog in 0.01 seconds

Expected Behavior

File /tmp/test is created without error with content:

# anything
{abc}$
# anything

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run puppet apply -e "file { '/tmp/test': ensure => 'file', content => \"# anything\n{abc}$\n# anything\" }"

Environment

  • Version 8.7.0
  • Platform Linux

Additional Context

  • This block triggers the deprecation warning and maybe the error too:
elsif value.is_a?(String) && checksum?(value)
  # XXX This is potentially dangerous because it means users can't write a file whose
  # entire contents are a plain checksum unless it is a Binary content.
  Puppet.puppet_deprecation_warning([
...

https://github.com/puppetlabs/puppet/blob/main/lib/puppet/type/file/content.rb#L50

  • The checksum() function is this:
# Is the provided string a checksum?
def checksum?(string)
  # 'sha256lite'.length == 10
  string =~ /^\{(\w{3,10})\}\S+/
end

https://github.com/puppetlabs/puppet/blob/main/lib/puppet/util/checksums.rb#L41

  • Any line that matches the RegEx in the checksum() function seems to trigger the error.
  • The whole functionality was scheduled to be removed in Puppet 7, but is still there. Ticket: https://puppet.atlassian.net/browse/PUP-1043
@tmu-sprd tmu-sprd added the bug Something isn't working label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant