[PUP-7032] Data Type Error Messages are Overly Verbose Created: 2016/12/19  Updated: 2019/03/28  Resolved: 2019/03/28

Status: Closed
Project: Puppet
Component/s: Language, Type System
Affects Version/s: PUP 4.8.1
Fix Version/s: None

Type: Improvement Priority: Normal
Reporter: Trevor Vaughan Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Team: Coremunity
QA Risk Assessment: Needs Assessment

 Description   

While creating some complex Data Types, i found the error messages to be too lengthy and complex to debug.

My recommendation is that the error message should contain the base types and not list the base 'Pattern' type since it tends to be unreadable and unweildy.

Example: https://github.com/simp/pupmod-simp-simplib/blob/master/types/netlist.pp

Provides the error message:

Failure/Error: is_expected.to compile
       error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Class[Simplib::Netlist]: parameter 'param' index 0 expects a match for Variant[Simplib::IP::V4 = Pattern[/^(?-mix:\A((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\z)$/], Simplib::IP::V6::Base = Pattern[/^(?x-mi:(?:(?x-mi:\A(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}:){6,6})(\d+)\.(\d+)\.(\d+)\.(\d+)\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}:)*)(\d+)\.(\d+)\.(\d+)\.(\d+)\z)))$/], Simplib::IP::V6::Bracketed = Pattern[/^(?x-mi:(?:(?x-mi:\A\[(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\]\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\]\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}:){6,6})(\d+)\.(\d+)\.(\d+)\.(\d+)\]\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}:)*)(\d+)\.(\d+)\.(\d+)\.(\d+)\]\z)))$/], Simplib::Hostname = Pattern[/^(?i-mx:(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]{2}|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\.?)$/], Simplib::IP::V4::CIDR = Pattern[/^(?-mix:\A((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\/(3[012]|[12][0-9]|[0-9])\z)$/], Simplib::IP::V4::DDQ = Pattern[/^(?-mix:\A((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\/(((0|128|192|224|240|248|252|254)\.0\.0\.0)|(255\.(0|128|192|224|240|248|252|254)\.0\.0)|(255\.255\.(0|128|192|224|240|248|252|254)\.0)|(255\.255\.255\.(0|128|192|224|240|248|252|254)))\z)$/], Simplib::IP::V4::Port = Pattern[/^(?-mix:\A((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?))\.((?x-mi:0|1(?:[0-9][0-9]?)?|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?)):([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z)$/], Simplib::IP::V6::CIDR = Pattern[/^(?x-mi:(?:(?x-mi:\A(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\/(12[0-8]|1[01][0-9]|[0-9]?[0-9])\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\/(12[0-8]|1[01][0-9]|[0-9]?[0-9])\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}:){6,6})(\d+)\.(\d+)\.(\d+)\.(\d+)\/(12[0-8]|1[01][0-9]|[0-9]?[0-9])\z))|(?:(?x-mi:\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}:)*)(\d+)\.(\d+)\.(\d+)\.(\d+)\/(12[0-8]|1[01][0-9]|[0-9]?[0-9])\z)))$/], Simplib::IP::V6::Port = Pattern[/^(?x-mi:(?:(?x-mi:\A\[(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\]:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\]:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}:){6,6})(\d+)\.(\d+)\.(\d+)\.(\d+)\]:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z))|(?:(?x-mi:\A\[((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}:)*)(\d+)\.(\d+)\.(\d+)\.(\d+)\]:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z)))$/]], got 'a' at line 6:9 on node xenotop



 Comments   
Comment by Henrik Lindberg [ 2016/12/20 ]

Ping Thomas Hallgren, maybe skip the pattern when it is aliased?

Comment by Thomas Hallgren [ 2016/12/20 ]

We used to do that and got complains that it was hard to determine what was wrong when only the alias was shown. This is especially true for types that the user has no knowledge of.

Comment by Henrik Lindberg [ 2016/12/20 ]

This is a "pick your poison" problem... Not sure what to do here. Possibly truncate if pattern is too long but display if --debug is one or something?

Comment by Trevor Vaughan [ 2016/12/20 ]

Henrik Lindberg and Thomas Hallgren I think that I would like to see a few levels of configuration for this.

  • Default
    • Truncate Patterns at 10 characters if it's over 20 characters or something like that
    • Add vertical spacing
    • Do not truncate anything else
  • --debug
    • What you have now with vertical spacing
  • Oneline (or something)
    • Generally for reporting, What would be sent to PuppetDB or a Log Server

Also, syntax highlighting would help a lot if possible. At least to help break up where the data types start and stop. This is particularly true of Structs and Tuples where the order and layout matters. Arrays and basic Hashes are easy.

I suppose that my main issue is just readability and being able to actually figure out what didn't match.

Since the Types are namespaced, I easily know where to find the Type definition. I get that it's difficult to debug but I need to quickly be able to hop in and figure out what's going on and I'm finding myself overwhelmed with the error messages. I basically need to break them out and format them manually to figure out what's actually wrong.

Spaced Example:

error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Class[Simplib::Ip]: parameter 'param' expects a match for:
Variant[
  Simplib::IP::V4 = Pattern[/^(?-mix:\A{...}],
  Simplib::IP::V6::Base = Pattern[/^(?x-mi:(?:{...}],
  Simplib::IP::V6::Bracketed = Pattern[/^(?x-mi:(?{...}]
]
, got 'foobar' at line 6:9 on node test.node

Also, the first line has a lot of information that doesn't really help me debug until halfway through the line.

Putting the information that I need up front would be really helpful.

Perhaps something like the following:

Error in Class[Simplib::Ip] at line 6:9: parameter 'param' got 'foobar', expects:
Variant[
  Simplib::IP::V4 = Pattern[/^(?-mix:\A{...}],
  Simplib::IP::V6::Base = Pattern[/^(?x-mi:(?:{...}],
  Simplib::IP::V6::Bracketed = Pattern[/^(?x-mi:(?{...}]
]
, on node test.node

This way I know exactly where to look immediately and can pretty much ignore the error message if it's code that I've just been tinkering with.

If not, it at least points me to a quick grep debugging run and/or tells me exactly what files I should be starting to open so that I can compare what's going on (is the Type incorrectly assigned, or did I mess up my data? What does this thing expect and why?).

Hopefully this is helpful.

Comment by Henrik Lindberg [ 2016/12/21 ]

File and line information are always added last to error messages. If we add that earlier in the message itself they will appear twice.

  • henrik
Comment by Josh Cooper [ 2019/03/28 ]

Given lack of movement on this, closing as won't fix.

Generated at Fri Dec 13 07:22:37 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.