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

[BUG]: YAML literal date variables are parsed as date #4530

Closed
1 of 4 tasks
qetza opened this issue Nov 16, 2023 · 6 comments
Closed
1 of 4 tasks

[BUG]: YAML literal date variables are parsed as date #4530

qetza opened this issue Nov 16, 2023 · 6 comments

Comments

@qetza
Copy link

qetza commented Nov 16, 2023

What happened?

Hi,
When defining variable values in YAML that that represents literal dates those values are always parsed as datetime instead of being left as strings so the value is not the one expected. This does not happen with variable group values.

Example of YAML build:

pool:
  vmImage: ubuntu-latest

trigger: none

variables:
- name: dateWithoutQuotes
  value: 2020-01-01T22:32:00Z
- name: dateWithSingleQuotes
  value: '2020-01-01T22:32:00Z'
- name: dateWithDoubleQuotes
  value: "2020-01-01T22:32:00Z"
- name: dateWithExplicitType
  value: !!str 2020-01-01T22:32:00Z
- group: "issue-325"

steps:
- pwsh: 'gci env:'
  displayName: dump env

The variable group issue-325 has the following variables:
image

Here is the output of the task dumping the environment variables with the variable values:
image

As you can see only the variable from the variable group has kept it's original value all others were parsed as datetime even though the values are quoted or explicitly set as string.

This is making issues with the users of my task replace tokens (issues qetza/vsts-replacetokens-task#325 and qetza/vsts-replacetokens-task#176)

Is there any way to force the string value (no parsing) or is this an issue in the agent when reading YAML variables?

Thanks

Versions

Azure DevOps Services

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu Latest

Version controll system

Azure Git Repository

Relevant log output

No response

@ismayilov-ismayil
Copy link
Contributor

Hi @qetza, thanks for reporting.

Could you please check triple single quote as escape symbol as shown below:

- name: dateWithEscape
  value: '''2020-01-01T22:32:00Z'''

@qetza
Copy link
Author

qetza commented Nov 19, 2023

Hi @ismayilov-ismayil,
Using the triple single quote will avoid the parsing as datetime but the single quotes are kept in the value:
image

@qetza
Copy link
Author

qetza commented Nov 30, 2023

Hi @ismayilov-ismayil,
Any news on this issue?

@ZackE4
Copy link

ZackE4 commented Jan 30, 2024

Hi @qetza I encountered the same issue and was able to work around it by setting the variable type to secret, this caused the pipeline to treat it as a string literal rather than a date

@qetza
Copy link
Author

qetza commented Feb 6, 2024

@ZackE4, thanks for the workaround.
@ismayilov-ismayil an news on a fix?

Copy link

github-actions bot commented Aug 4, 2024

This issue has had no activity in 180 days. Please comment if it is not actually stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants