Skip to content

stdlib::manage: "Illegal Resource Type expression, got String" when using file resource type #1473

Description

@pebtron

Describe the Bug

In manifests/manage.pp line 107, the file (and concat::fragment) branch declares resources using a String variable as the resource type:

$type { $title:
* => $attributes - 'erb' - 'epp' - 'content',
content => $content,
}

Puppet rejects this with:

Evaluation Error: Illegal Resource Type expression, expected result to be a type name, or untitled Resource, got String

The default branch already handles this correctly via create_resources(), but the file/concat::fragment branch does not.

Expected Behavior

Defining a file resource via stdlib::manage::create_resources in Hiera (e.g. stdlib::manage::create_resources: file: ...) should successfully create the resource without a catalog compilation error.

Steps to Reproduce

  1. Upgrade puppetlabs-stdlib to 10.0.0
  2. Add a stdlib::manage::create_resources entry with type file in node Hiera:
stdlib::manage::create_resources:
  file:
    'blocklist.acl':
      content: |
        1.2.3.4
        5.6.7.8
      mode: '0644'
  1. Run puppet agent on that node

Environment

  • Version: 10.0.0
  • Platform: Ubuntu 24.04

Additional Context

The default branch on line 113 uses create_resources($type, { $title => $attributes }) and works correctly. The file/concat::fragment branch should do the same, passing the computed $content merged into the attributes hash rather than using a dynamic resource type expression.

Claude provided me with this proposed diff. My environment doesn't have instances of stdlib::manage::create_resources using epp or erb files to test with so I'm not submitting a PR.

--- a/manifests/manage.pp
+++ b/manifests/manage.pp
@@ -104,9 +104,7 @@ class stdlib::manage (
           } else {
             $content = undef
           }
-          $type { $title:
-            *       => $attributes - 'erb' - 'epp' - 'content',
-            content => $content,
-          }
+          create_resources($type, { $title => $attributes - 'erb' - 'epp' - 'content' + { 'content' => $content } })
         }
         default: {
           create_resources($type, { $title => $attributes })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions