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

System for reporting warnings (soft errors) #27

Merged
merged 4 commits into from
Mar 7, 2024

Conversation

DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Feb 22, 2024

Description

  • Add a new system for reporting soft errors (called warnings) through the error interface.
  • Respect warnings in the various layers of the parser: rather than return immediately, accumulate warnings and return them together at the end.
  • Add new warnings where some errors were previously dropped when falling back to UnknownStep, and where a pipeline is parsed with no steps.

Background

We have some cases in the parser where, when a failure occurs, parsing continues but producing a pipeline with lower semantic information:

  • (Resilience) Maybe this parser has a bug, and we'd rather upload something if there's a chance the backend will accept it than block the user
  • (Future compatibility) Maybe we want to introduce a new step type in the future, but allow older agents to continue to upload pipelines without knowing about them

There may be other reasons. These all boil down to "this package is not the authoritative specification for pipeline YAML".

However, silently dropping errors is not great, when they could be used to diagnose why a pipeline isn't being interpreted correctly. Without vigilance, it's easy to write YAML that looks like one thing but is parsed as another. For example:

- command: echo hello
  env:
    KEY: {"this_json":"should have been quoted"}
  branches: !main

will not parse correctly because

  • the env block requires strings for values, yet the inline JSON will be parsed as a mapping (this is true here and on the backend)
  • ! has special meaning in YAML when not quoted, so it will end up with branches: ''

@DrJosh9000 DrJosh9000 requested a review from a team February 22, 2024 04:13
@DrJosh9000 DrJosh9000 changed the title Include parse error inside UnknownType System for reporting warnings (soft errors) Feb 27, 2024
Copy link
Collaborator

@moskyb moskyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one super tiny nit, but other than that this looks awesome! great work

steps.go Outdated Show resolved Hide resolved
@DrJosh9000 DrJosh9000 merged commit 1e349ad into main Mar 7, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the ps-46-silent-parse-failures branch March 7, 2024 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants