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

relay-compiler diagnostic errors logging improvements #4574

Closed
wants to merge 1 commit into from

Conversation

alex-statsig
Copy link
Contributor

@alex-statsig alex-statsig commented Jan 10, 2024

Couple of improvements to relay compiler error output to address issues from #4571

  1. Update diagnostic.print_without_source() to no longer include character ranges since the formatting of startchar:endchar doesnt match the standard expectation of linenumber:character (and thus editors will interpret it wrong)
  2. Updated the ValidationErrors to no longer enumerate all errors, and instead show the count (since the actual errors are shown above anyway)

Test Plan

Confirmed the new formatting of .print_without_source() is correct with no character ranges (tested via ValidationError since I'm not sure how to generate a DiagnosticsError, but this will no longer be triggered due to the summarization change):

[INFO] Querying files to compile...
[INFO] [default] compiling...
[ERROR] Error: ✖︎ The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/

  client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx:20:7
   19 │       configuration_json
   20 │       test
      │       ^^^^
   21 │     }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
 - Validation errors:
 - The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/: client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx

Confirmed the count shows instead of the individual errors now:

[INFO] Querying files to compile...
[INFO] [default] compiling...
[ERROR] Error: ✖︎ The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/

  client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx:20:7
   19 │       configuration_json
   20 │       test
      │       ^^^^
   21 │     }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
 - Validation errors: 1 error(s) encountered above.

Also confirmed that config errors still showed up correctly:

[ERROR] Config `/Users/alex/dev/statsig/console/relay.config.js` is invalid:
 - The `schema` configured for project `default` does not exist at `./server/lib/graphql/schedma.graphql`.

1. Update diagnostic.print_without_source() to no longer include character ranges since the formatting of startchar:endchar doesnt match the standard expectation of linenumber:character (and thus editors will interpret it wrong)
2. Updated the ValidationErrors to no longer enumerate all errors, and instead show the count (since the actual errors are shown above anyway)

# Test Plan

Confirmed the new formatting of .print_without_source() is correct with no character ranges (tested via ValidationError since I'm not sure how to generate a DiagnosticsError, but this will no longer be triggered due to the summarization change):
```
[INFO] Querying files to compile...
[INFO] [default] compiling...
[ERROR] Error: ✖︎ The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/

  client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx:20:7
   19 │       configuration_json
   20 │       test
      │       ^^^^
   21 │     }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
 - Validation errors:
 - The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/: client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx
```

Confirmed the count shows instead of the individual errors now:
```
[INFO] Querying files to compile...
[INFO] [default] compiling...
[ERROR] Error: ✖︎ The type `CustomMetric` has no field `test`.
See https://relay.dev/docs/error-reference/unknown-field/

  client/components/console/metrics_catalog/MetricDefinitionDebugDialog.tsx:20:7
   19 │       configuration_json
   20 │       test
      │       ^^^^
   21 │     }

[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
Failed to build:
 - Validation errors: 1 error(s) encountered above.

```

Also confirmed that config errors still showed up correctly:
```
[ERROR] Config `/Users/alex/dev/statsig/console/relay.config.js` is invalid:
 - The `schema` configured for project `default` does not exist at `./server/lib/graphql/schedma.graphql`.
@alex-statsig
Copy link
Contributor Author

I could update DiagnosticsError to have the same summarization change, but I'm not familiar with how to trigger that / if it shows those messages elsewhere or not

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@captbaritone
Copy link
Contributor

This is great! Thanks for coming through with the PR and for the detailed test plan.

@facebook-github-bot
Copy link
Contributor

@captbaritone merged this pull request in a2c7ed4.

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

Successfully merging this pull request may close these issues.

3 participants