java.lang.IllegalArgumentException: Resource '{:type "Notify", :title "two\nlines"}' has an invalid tag 'two lines'. Tags must match the pattern /\A[a-z0-9_][a-z0-9_:\-.]*\Z/.

JIRA | Charlie Sharpsteen | 8 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    The Puppet compiler uses the following regex to determine whether or not a tag\ is valid: {code} ^[0-9A-Za-z_][0-9A-Za-z_:.-]*$ {code} This regex has an issue in that validation will stop at the first newline character in a tag. PuppetDB uses a stricter regex that will reject any tag containing newlines: {code} \A[a-z0-9_][a-z0-9_:\-.]*\Z {code} This rejection causes PuppetDB to discard catalogs containing resources tagged with strings containing newlines. h2. Reproduction Case Install PE 2016.2.1 and add the following resource to the default node declaration in {{/etc/puppetlabs/code/environments/production/manifests/site.pp}}: {code:puppet} notify {"two\nlines": } {code} Run {{puppet agent -t}}. h3. Outcome The catalog compiles and applies just fine: {noformat} # puppet agent -t Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Info: Caching catalog for pe-201621-master.puppetdebug.vlan Info: Applying configuration version '1472744920' Notice: two lines {noformat} However, errors are present in the PuppetDB log: {noformat} 2016-09-01 08:48:49,635 ERROR [p.p.mq-listener] [a7244661-f9cd-469c-bfac-ca35be92db5c] [replace catalog] Fatal error on attempt 0 for pe-201621-master.puppetdebug.vlan java.lang.IllegalArgumentException: Resource '{:type "Notify", :title "two\nlines"}' has an invalid tag 'two lines'. Tags must match the pattern /\A[a-z0-9_][a-z0-9_:\-.]*\Z/. at puppetlabs.puppetdb.catalogs$validate_resources.invokeStatic(catalogs.clj:303) ~[na:na] at puppetlabs.puppetdb.catalogs$validate_resources.invoke(catalogs.clj:294) ~[na:na] ... {noformat} And a query to the PuppetDB node endpoint shows that a new set of facts was stored along with a new report, but the catlog is out of date: {noformat} # curl http://127.0.0.1:8080/pdb/query/v4/nodes/$(hostname -f)f) { "deactivated" : null, "latest_report_hash" : "221e50f615f0320d22c276dd4c4cc01634ba0841", "facts_environment" : "production", "cached_catalog_status" : "not_used", "report_environment" : "production", "catalog_environment" : "production", "facts_timestamp" : "2016-09-01T15:56:58.329Z", "latest_report_noop" : false, "expired" : null, "report_timestamp" : "2016-09-01T15:57:14.151Z", "certname" : "pe-201621-master.puppetdebug.vlan", "catalog_timestamp" : "2016-09-01T01:57:03.472Z", "latest_report_status" : "changed" } {noformat} h3. Expected Outcome The Puppet compiler uses {{/A}} and {{/Z}} to validate tags so that newlines don't break validation.

    JIRA | 8 months ago | Charlie Sharpsteen
    java.lang.IllegalArgumentException: Resource '{:type "Notify", :title "two\nlines"}' has an invalid tag 'two lines'. Tags must match the pattern /\A[a-z0-9_][a-z0-9_:\-.]*\Z/.

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Resource '{:type "Notify", :title "two\nlines"}' has an invalid tag 'two lines'. Tags must match the pattern /\A[a-z0-9_][a-z0-9_:\-.]*\Z/.

      at puppetlabs.puppetdb.catalogs$validate_resources.invokeStatic()
    2. puppetlabs.puppetdb
      catalogs$validate_resources.invoke
      1. puppetlabs.puppetdb.catalogs$validate_resources.invokeStatic(catalogs.clj:303)[na:na]
      2. puppetlabs.puppetdb.catalogs$validate_resources.invoke(catalogs.clj:294)[na:na]
      2 frames