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

Check if a workflow payload is valid during sync #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agrare
Copy link
Member

@agrare agrare commented Nov 8, 2023

When syncing a repository and creating workflows check if the payload is valid and if it isn't set a (hopefully) helpful error message.

Depends on:

TODO:

  • We don't currently check if a configuration_script_payload "supports" running, we could enable that and check for validity there and use payload_error as the unsupported reason

@agrare agrare added the enhancement New feature or request label Nov 8, 2023
@Fryguy
Copy link
Member

Fryguy commented Nov 8, 2023

I think it would be cool in the UI if you could see the payload_valid as a ✅ or ❌ in the table, then perhaps have the error on mouse over. Or, at a minimum show the value on the summary page.

@agrare
Copy link
Member Author

agrare commented Nov 8, 2023

I really want to write some specs for this, the way the fake repo is set up it makes it difficult to setup an invalid file for a single test. Going to play with that a little bit

found.update!(:name => filename, :manager_id => manager_id, :payload => payload, :payload_type => "json")
payload_valid, payload_error =
begin
Floe::Workflow.new(payload)
Copy link
Member

Choose a reason for hiding this comment

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

If the payload is very broken, like bad JSON broken, will it still raise a Floe::InvalidWorkflowError ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Fryguy Fryguy closed this Nov 13, 2023
@Fryguy Fryguy reopened this Nov 13, 2023
@Fryguy
Copy link
Member

Fryguy commented Nov 13, 2023

I was just thinking - with the new column, we defaulted to valid (because I suggested it), but do we want a tri-boolean column? 😉...in all seriousness though, I could see valid, invalid and unknown, and the ansible ones could be unknown? I started thinking about my comment visualizing them in a table, and then I got to thinking how we want to collapse these views together and it might be weird to see ansible as "valid" even though we didn't verify them? Thoughts?

@agrare
Copy link
Member Author

agrare commented Nov 13, 2023

Hm would It be weird that payload_valid? on nil would be false when we just didn't check?
If we did have logic to say "valid", "invalid" or "unknown" would we show e.g. a grey question mark on the UI? There's nothing the user could do to verify it though.

@Fryguy
Copy link
Member

Fryguy commented Nov 14, 2023

Yeah I was thinking a gray question mark. Alternatively we could always add some basic ansible validation. (YAML parses, has a certain structure, etc)

Comment on lines 45 to 63
def each_file
git_repository.update_repo
git_repository.with_worktree do |worktree|
worktree.ref = scm_branch
worktree.blob_list.each do |filename|
next if filename.start_with?(".") || !filename.end_with?(".asl")

payload = worktree.read_file(filename)
yield filename, payload
end
end
end
Copy link
Member Author

Choose a reason for hiding this comment

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

Think this would be better in core's EmbeddedAutomationManager repository class but I wanted to test it out self-contained here.

@miq-bot miq-bot added the stale label Mar 11, 2024
@miq-bot
Copy link
Member

miq-bot commented Mar 11, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

@kbrock
Copy link
Member

kbrock commented Apr 5, 2024

Can we merge this even with valid column being true/false?

When syncing a repository and creating workflows check if the payload is
valid and if it isn't set a (hopefully) helpful error message.
@agrare agrare force-pushed the check_workflows_payload_validity branch from 4c83d36 to 6275276 Compare April 8, 2024 16:02
@miq-bot
Copy link
Member

miq-bot commented Apr 8, 2024

Checked commit agrare@6275276 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
3 files checked, 0 offenses detected
Everything looks fine. 👍

@miq-bot
Copy link
Member

miq-bot commented May 27, 2024

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Sep 9, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

@miq-bot miq-bot added the stale label Sep 9, 2024
@miq-bot
Copy link
Member

miq-bot commented Dec 16, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

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

Successfully merging this pull request may close these issues.

4 participants