[PUP-7835] undefined method `from' for #<Puppet::Pops::Types::PStructType:0x6d4ca435> Created: 2017/08/11  Updated: 2017/09/14  Resolved: 2017/09/06

Status: Closed
Project: Puppet
Component/s: Language
Affects Version/s: PUP 5.0.1
Fix Version/s: PUP 5.2.0

Type: Bug Priority: Normal
Reporter: Matteo Cerutti Assignee: John Duarte
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Team: Platform Core
Method Found: Needs Assessment
Release Notes: Bug Fix
Release Notes Summary: A type mismatch involving an aliased Struct type would cause an "undefined method 'from'" error. This bug is now fixed.
QA Risk Assessment: Manual

 Description   

The problem occurs when including a class that might look like the following:

class test (
  String $var,
  Test::Options $opts
) {
}

Let's assume that Test::Options is defined as:

type Test::Options = Struct[{
  var => String
}]

If the 'var' parameter doesn't get passed to the test class, an evaluation error would be generated as expected. This works indeed.

However, one would expected to see the same evaluation error popping up if var is not specified in the 'opts' hash, since it is required. Instead, the following error occurs:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Method call, undefined method `from' for #<Puppet::Pops::Types::PStructType:0x6d4ca435>

This problem does not occur when using puppet apply (masterless).



 Comments   
Comment by Kenn Hussey [ 2017/08/14 ]

Thomas Hallgren which version should this target, perhaps 5.2?

Comment by John Duarte [ 2017/09/06 ]

This passes manual validation using a pre-release version of puppet-agent at SHA 796a4c6 containing puppet at SHA 8a6d519.

The expected evaluation error for the lack of expected arguments in the defined type is presented when evaluating the example in the description of this ticket.

root@oh236yl4nwbjnhs:~# cat test.pp
type Test::Options = Struct[{
  var => String
}]
 
class test (
  String $var,
  Test::Options $opts
) {
}
 
class {'test': var => 'foo', opts => { } }
root@oh236yl4nwbjnhs:~# puppet apply test.pp
Error: Evaluation Error: Error while evaluating a Resource Statement, Class[Test]: parameter 'opts' expects size to be 1, got 0 at /root/test.pp:11:1 on node oh236yl4nwbjnhs.delivery.puppetlabs.net

Comment by John Duarte [ 2017/09/06 ]

Thomas Hallgren, would you please add release notes to this issue?

Generated at Mon Dec 09 01:53:20 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.