Skip to content

fix: include cause of parsing errors in action output logs #431

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

Merged
merged 6 commits into from
May 6, 2025

Conversation

zimeg
Copy link
Member

@zimeg zimeg commented Apr 22, 2025

Summary

This PR includes the cause of parsing errors in action output logs to fix #359.

Requirements

Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (c7dafcf) to head (b0c83a8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #431   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files           7        7           
  Lines         703      709    +6     
=======================================
+ Hits          702      708    +6     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zimeg
Copy link
Member Author

zimeg commented Apr 22, 2025

📝 Example of invalid YAML:
https://github.com/zimeg/slack-sandbox/actions/runs/14603929191/job/40968479290#step:2:12

YAMLException: bad indentation of a mapping entry (2:19)

 1 | channel: ***,
 2 | text: "greetings!",
-----------------------^

📝 Example of invalid JSON:
https://github.com/zimeg/slack-sandbox/actions/runs/14603970704/job/40968613223#step:2:13

SyntaxError: Expected ',' or '}' after property value in JSON at position 52
    at JSON.parse (<anonymous>)

📝 Example of invalid attributes:
https://github.com/zimeg/slack-sandbox/actions/runs/14604005898/job/40968725587#step:2:14

Error: missing required field: channel
Error: SlackError: An API error occurred: invalid_arguments
Error: An API error occurred: invalid_arguments

Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

📣 A note on some strange patterns in these changes for the kind reviewers!

Comment on lines +13 to +21
/** @type {import('./errors.js').Cause} */
const causes = /** @type {any} */ (error.cause);
if (causes?.values) {
for (const cause of causes.values) {
core.info(`${cause.stack}`);
}
} else {
core.info(`${error.stack}`);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

🔗 The error cause values is valid data but typescript treats causes as "unknown" so this worksaround that.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause

@zimeg zimeg marked this pull request as ready for review April 22, 2025 20:31
Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

✅ LGTM! Huge improvement to the error messages. Hopefully this helps folks debug issues more easily!

@@ -6,13 +6,21 @@ import send from "./send.js";
* from the send.js file for testing purposes.
*/
try {
send(core);
await send(core);
Copy link
Member

Choose a reason for hiding this comment

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

🎉

@zimeg
Copy link
Member Author

zimeg commented May 1, 2025

📝 Example of invalid YAML file:
https://github.com/zimeg/slack-sandbox/actions/runs/14770123380/job/41468715105#step:3:10

YAMLException: expected a single document in the stream, but found more
    at Object.load$1 [as load] (file:///home/runner/work/_actions/zimeg/slack-github-action/v2.0.1-rc.5/node_modules/js-yaml/dist/js-yaml.mjs:2812:1)

📝 Example of invalid JSON file:
https://github.com/zimeg/slack-sandbox/actions/runs/14770064204/job/41468560233#step:3:11

SyntaxError: Bad control character in string literal in JSON at position 21
    at JSON.parse (<anonymous>)

📝 Example of missing file:
https://github.com/zimeg/slack-sandbox/actions/runs/14770087484/job/41468622000#step:3:12

Error: ENOENT: no such file or directory, open '/home/runner/work/slack-sandbox/slack-sandbox/oop.yaml'
    at Object.readFileSync (node:fs:449:20)

@zimeg
Copy link
Member Author

zimeg commented May 1, 2025

📝 Example of invalid arguments from a payload file too:
https://github.com/zimeg/slack-sandbox/actions/runs/14770107368/job/41468674575#step:3:14

Error: missing required field: channel
Error: SlackError: An API error occurred: invalid_arguments
Error: An API error occurred: invalid_arguments

@zimeg
Copy link
Member Author

zimeg commented May 6, 2025

@mwbrooks @hello-ashleyintech 🫡

With both unexpected text and file inputs returning perhaps more meaningful errors, let's merge this! I might imagine follow up that continues to improve upon these outputs, perhaps logging the actual inputs, but for now this I hope is helpful.

After this merges, I will test a release candidate a few times for confidence. Then I look forward to a new release 🚀

@zimeg zimeg merged commit ab965e5 into slackapi:main May 6, 2025
5 checks passed
@zimeg zimeg modified the milestones: 2.0.1, 2.1 May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semver:patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error reporting when action fail to parse correctly the payload
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy