Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7757

Successful parsing of timestamp should raise error unless complete string is parsed

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.10.4, PUP 5.0.0
    • Fix Version/s: PUP 5.1.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Sub-team:
    • Team:
      Agent
    • Story Points:
      1
    • Sprint:
      Agent 2017-07-12
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      If a {{Timestamp}} was created from a string with trailing unrecognized characters there would be no error and the produced {{Timestamp}} would be based on only the recognized part. This will now instead raise an error.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      Covered by spec tests

      Description

      The following puppet expression is valid:

      notice(Timestamp('1969-08-20T20:18:00 UTC, one giant leap for mankind'))
      

      will run without errors and notice:

      1969-08-20T20:18:00.000000000 UTC
      

      This is because one of the default formats successfully parsed the string and managed to satisfy all of its format specifiers.

      It would be desirable if Puppet could detect that the string contains trailing garbage and raise an error. Doing so is not trivial however. The Timestamp class currently relies on the DateTime#strptime function which provides no means to detect the garbage so solving this means writing a new parser.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                thomas.hallgren Thomas Hallgren
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support