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

ANE-1254: Error Structure #1364

Merged
merged 22 commits into from
Feb 13, 2024
Merged

ANE-1254: Error Structure #1364

merged 22 commits into from
Feb 13, 2024

Conversation

JeffreyHuynh1
Copy link
Contributor

@JeffreyHuynh1 JeffreyHuynh1 commented Jan 17, 2024

Overview

As a fossa user, errors should be structured.

Acceptance criteria

  • Errors have a structure similar to broker:

Screenshot 2024-01-28 at 10 24 43 PM

Testing plan

  • Manually tested new error structure implementation

Here are how errors are structured now:

Screenshot 2024-01-28 at 5 59 47 PM

Screenshot 2024-01-28 at 6 00 00 PM

You can also test by triggering an error.

Risks

  • Changes to renderDiagnostic. Instead of rendering errors to Doc AnsiStyle, this implementation renders errors to an Errata object.

Metrics

References

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this PR added docs, I added links as appropriate to the user manual's ToC in docs/README.ms and gave consideration to how discoverable or not my documentation is.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an # Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json AND I have updated example files used by fossa init command. You may also need to update these if you have added/removed new dependency type (e.g. pip) or analysis target type (e.g. poetry).
  • If I made changes to a subcommand's options, I updated docs/references/subcommands/<subcommand>.md.

@JeffreyHuynh1
Copy link
Contributor Author

There was a pretty big change in this pr that changed the way we render errors to our diagnostic. Instead of rendering everything as Doc AnsiStyle, it has been changed to return an Errata object. Currently, we aren't necessarily doing much with the Errata module aside from using the source location and basic rendering features.

However, Errata allows you to highlight code blocks and add styling using pointers / underlines. I think that this might be beneficial in cases where we come across errors when parsing things like our fossa-deps / .fossa config files. This would work probably need to done later down the line.

I would like to get thoughts on this implementation and if it's too big of a change.

@JeffreyHuynh1
Copy link
Contributor Author

Additionally, we used to capture contextual information about error failures through our errCtx carrier. It held a lot of information such as troubleshooting, documentation references, and other contextual information. In order, to structure and label our errors similar to broker. I created additional carriers for errHelp, errDoc, and errSupport to allow us to easily categorize the various types of contextual info that can be attached to an error.

@JeffreyHuynh1 JeffreyHuynh1 marked this pull request as ready for review January 29, 2024 16:47
@JeffreyHuynh1 JeffreyHuynh1 requested a review from a team as a code owner January 29, 2024 16:47
Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

I'm about 3/4 of the way through reviewing, and running out of steam 😅

I'm going to submit this for now, and continue reviewing on Monday

Note to self: I'm at src/Strategy/Conan/ConanGraph.hs

src/Data/Error.hs Outdated Show resolved Hide resolved
src/Data/Error.hs Outdated Show resolved Hide resolved
src/App/Fossa/Analyze.hs Outdated Show resolved Hide resolved
src/App/Fossa/Analyze.hs Outdated Show resolved Hide resolved
src/App/Support.hs Outdated Show resolved Hide resolved
src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs Outdated Show resolved Hide resolved
src/Data/Error.hs Outdated Show resolved Hide resolved
src/Effect/Exec.hs Outdated Show resolved Hide resolved
src/Effect/Exec.hs Outdated Show resolved Hide resolved
src/Strategy/Bundler.hs Show resolved Hide resolved
Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

This is a great change, and I love the look of the new error structure.

However, I have a few questions:

  1. Is the use of ImplicitParams reasonable. I'd like to get a sanity check from someone else on the team on this. If you've already run this by someone else, then that counts as a sanity check

  2. Are the colour codes in scan-summary.txt okay, or should we strip them out when writing to scan-summary.txt

  3. Is there any way we can add tests for this change. As I said in the comment below, I'm fine with these coming in a separate PR

I'd like to get answers on these before I approve. But it's looking great other than those questions!

src/Strategy/Scala/Errors.hs Outdated Show resolved Hide resolved
docs/contributing/diagnostics.md Show resolved Hide resolved
@@ -6,7 +6,8 @@ import Control.Carrier.Telemetry (withoutTelemetry)
import Control.Effect.Diagnostics (ToDiagnostic (..), fatal)
import Data.Text (Text)
import Effect.Exec (ExitCode (..))
import Effect.Logger (ignoreLogger, logInfo, pretty)
import Effect.Logger (ignoreLogger, logInfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a scarily small ratio of test change to code change.

It could be that there are a bunch of tests for error cases but the changes in this PR don't affect those tests. In that case, the error code is being exercised by the tests and all is good.

If there are no tests on most of these errors currently, we should fix this up. I'm fine with doing that in a separate PR, as this one is huge.

If you've thought about this and come to the conclusion that this is too hard, that's reasonable, but it should be documented in the PR description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I'm going to create a separate ticket to add more tests. I agree, I was pretty shocked when I saw the state of our test coverage here.

@JeffreyHuynh1
Copy link
Contributor Author

More diagnostic test cases will be added in a separate ticket!

Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

This looks great. 🚢

@JeffreyHuynh1 JeffreyHuynh1 merged commit 8843618 into master Feb 13, 2024
16 checks passed
@JeffreyHuynh1 JeffreyHuynh1 deleted the ANE-1254 branch February 13, 2024 22:07
@JeffreyHuynh1 JeffreyHuynh1 mentioned this pull request Feb 13, 2024
6 tasks
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.

3 participants