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

Timestamp value does not accept string as input #325

Open
Clebam opened this issue Jun 21, 2024 · 1 comment
Open

Timestamp value does not accept string as input #325

Clebam opened this issue Jun 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Clebam
Copy link
Contributor

Clebam commented Jun 21, 2024

Describe the Bug

When providing a timestamp formatted string to a parameter that requires Timestamp type, it throws expects a value of type Undef or Timestamp, got String

Expected Behavior

The string should be accepted, then parsed into Timestamp.

Steps to Reproduce

Using the module computermanagementdsc : https://forge.puppet.com/modules/dsc/computermanagementdsc/readme
Using the resource dsc_scheduledtask

  dsc_scheduledtask { "my_task":
    dsc_ensure            => present,
    dsc_enable            => true,
    dsc_taskname          => "my_task",
    dsc_actionexecutable  => 'ping.exe',
    dsc_actionarguments   => "localhost",
    dsc_actionworkingpath => '',
    dsc_scheduletype      => 'daily',
    dsc_starttime         => '2024-06-19T22:00:00',
    dsc_daysinterval      => 1,
  }

(Please note I tried a few different string format, but it always ends up with the same error)

Puppet run output:

Error: Failed to apply catalog: Parameter dsc_starttime failed on Dsc_scheduledtask[my_task]: dsc_scheduledtask.dsc_starttime expects a value of type Undef or Timestamp, got String

Environment

  • Version puppet 7.23
  • Platform Windows 2022

Additional Context

So I spent some time trying to debug the issue.
I looked at dsc_base_provider.rb source code and the code added with this PR : #57 is working fine as far as I can tell.
The type comparison seems to be done elsewhere, but I can't find it.
I also tried to force timestamp time with Timestamp.new() but received the error

Error: Failed to apply catalog: Parameter dsc_starttime failed on Dsc_scheduledtask[my_task]: dsc_scheduledtask.dsc_starttime expects a value of type Undef or Timestamp, got Type[Timestamp]

The dsc_starttime parameter is defined as this in the module:

dsc_starttime: {
  type: 'Optional[Timestamp]',
  desc: 'The time of day this task should start at - defaults to 12:00 AM. Not valid for AtLogon and AtStartup tasks.',
  mandatory_for_get: false,
  mandatory_for_set: false,
  mof_type: 'DateTime',
  mof_is_embedded: false,
},

I tried to modify with Optional[String] and Variant[Timestamp, String, Undef] but this raised other issues and seems to be a wrong hack.

So far I do not have much more idea on what to do

@Clebam Clebam added the bug Something isn't working label Jun 21, 2024
@danadoherty639
Copy link
Contributor

@Clebam thank you for bringing this to our attention, we have raised a ticket in our backlog and will look into this

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
Archived in project
Development

No branches or pull requests

2 participants