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

[vrotsc] (#301) Improve error messages for Policy Template, Workflow and Configuration files with incorrect extensions #399

Merged

Conversation

bcpmihail
Copy link
Contributor

@bcpmihail bcpmihail commented Aug 28, 2024

Description

Replaces the non-specific error of the type "SyntaxError: [9:15]: Unexpected token: '-'" thrown when a file has an unsupported extension (e.g. .wf):

  • in the cases when a .ts Action file contains a Workflow, Configuration or PolicyTemplate decorator:
    confErr
    wfErr
    plErr

  • in the cases when the file extension is .pl, .wf, .conf (omitted .ts/.xml/.yaml extension):
    wfErr2
    plErr2
    confErr2

  • in the case of all other unsupported file extensions, the file is treated as Resource, retaining the existing behavior.

Checklist

  • I have added relevant error handling and logging messages to help troubleshooting
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation, relevant usage information (if applicable)
  • I have updated the PR title with affected component, related issue number and a short summary of the changes introduced
  • I have added labels for implementation kind (kind/) and version type (version/)
  • I have tested against live environment, if applicable
  • I have synced any structure and/or content vRA-NG improvements with vra-ng and ts-vra-ng archetypes (if applicable)
  • I have my changes rebased and squashed to the minimal number of relevant commits. Notice: don't squash all commits
  • I have added a descriptive commit message with a short title, including a Fixed #XXX - or Closed #XXX - prefix to auto-close the issue

Testing

Tested manually on a new TS archetype project.

Related issues and PRs

Closes #301

Throw errors for files with .pl, .conf, .wf extensions (without .ts / .xml / .yaml)
Includes fix for calling undefined function when extension is unsupported

Signed-off-by: Mihail Penchev (c) <[email protected]>
Check action .ts files for Configuration, Workflow, PolicyTemplate decorators, throw respective error

Signed-off-by: Mihail Penchev (c) <[email protected]>
@bcpmihail bcpmihail added kind/enhancement Enhancement or improvement of existing features lang/typescript Related to typescript code area/vrotsc Relates to `vrotsc` module version/minor Introduces a non-breaking feature or change triage/needed Needs to be discussed by project maintainers kind/feature New Feature to the project labels Aug 28, 2024
@bcpmihail bcpmihail self-assigned this Aug 28, 2024
@bcpmihail bcpmihail requested a review from a team as a code owner August 28, 2024 15:38
@VenelinBakalov VenelinBakalov added version/patch The change is a non-breaking bugfix and removed version/minor Introduces a non-breaking feature or change labels Aug 29, 2024
…o program.ts

Validation moved to a new helper used in resource transformer
Updated Release.md

Signed-off-by: Mihail Penchev (c) <[email protected]>
@VenelinBakalov VenelinBakalov changed the title [vrotsc] (#301) Better errors for Policy Template, Workflow and Configuration files with incorrect extensions [vrotsc] (#301) Improve error messages for Policy Template, Workflow and Configuration files with incorrect extensions Aug 30, 2024
Copy link
Collaborator

@VenelinBakalov VenelinBakalov left a comment

Choose a reason for hiding this comment

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

LGTM
Maybe we should wait for @Michaelpalacce as well to approve as he requested the original change

@VenelinBakalov VenelinBakalov merged commit 785e2f4 into main Sep 3, 2024
16 checks passed
@VenelinBakalov VenelinBakalov deleted the feature/301-error-wrong-filename-with-decorator branch September 3, 2024 08:07
@VenelinBakalov VenelinBakalov removed kind/feature New Feature to the project triage/needed Needs to be discussed by project maintainers labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vrotsc Relates to `vrotsc` module kind/enhancement Enhancement or improvement of existing features lang/typescript Related to typescript code version/patch The change is a non-breaking bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vrotsc should show better errors if you're using a decorator but the filename is not correct
2 participants