-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 outputted file links - bad format for VSCode #4571
Comments
This is great feedback thank you! I think the relevant code is here: https://github.com/facebook/relay/blob/main/compiler/crates/graphql-cli/src/diagnostic_printer.rs#L89 Would you be interested in opening a pull request? |
It looks like this actually coming from somewhere else: which calls into Location's toString: https://github.com/facebook/relay/blob/main/compiler/crates/common/src/location.rs#L86C3-L86C3 I'll put up a PR to fix the missing space, but converting the character span to line numbers seems a bit more involved, as I'm not sure the right information is being passed around to this Diagnostics object from a ton of callsites (in the code you linked, it actually is handled correctly by I'm still open to helping contribute that part, but it seems so much more involved that I would want a sanity check on the approach (adding location_range to DiagnosticsData) |
A space was missing between the error message and location in Diagnostic.print_without_source, which made it harder to open the file from terminal output with tools like vscode. See facebook#4571 # Test Plan Confirmed that now the path is outputted in a format that vscode can parse out: ``` [ERROR] Compilation failed. [ERROR] Unable to run relay compiler. Error details: Failed to build: - Validation errors: - The type `Company` has no field `metric`. Did you mean `metrics`? See https://relay.dev/docs/error-reference/unknown-field/: client/components/console/pulse/details_dialog/PulseMetricDetailsDialog.tsx:465:471 ``` Note that the line range is still incorrect (it is using the character span instead of linenumber:character), but this seems much trickier to fix.
Summary: Fix missing space in diagnostic location print A space was missing between the error message and location in Diagnostic.print_without_source, which made it harder to open the file from terminal output with tools like vscode. See #4571 Pull Request resolved: #4573 Test Plan: Confirmed that now the path is outputted in a format that vscode can parse out: ``` [ERROR] Compilation failed. [ERROR] Unable to run relay compiler. Error details: Failed to build: - Validation errors: - The type `Company` has no field `metric`. Did you mean `metrics`? See https://relay.dev/docs/error-reference/unknown-field/: client/components/console/pulse/details_dialog/PulseMetricDetailsDialog.tsx:465:471 ``` Note that the line range is still incorrect (it is using the character span instead of linenumber:character), but this seems much trickier to fix. Reviewed By: monicatang Differential Revision: D52635842 Pulled By: captbaritone fbshipit-source-id: fabc0aadb1b72deac2da377a44dd46afed46be60
I see. This is just the location information at the bottom of the CLI output which summarizes the errors emitted above? Do you have nicely formatted diagnostics above with the correct line numbers? |
Ah yeah I do, and that seems to show the correct ranges / format. In my case I had ~20 validation errors and missed the section above. Is there a reason to output the individual errors again at the bottom with worse formatting? Are some errors only listed in the bottom summary? Perhaps that section should just say Thanks a ton for the quick responses and help tracking this down btw! |
I think the report at the bottom serves two purposes. It serves as a terser summary of all the encountered errors, and it also includes non-diagnostic errors such as config errors, etc.. I think replacing the diagnostics that appear here with a message that just includes the count does seem more reasonable. |
I think the two places we build those lists are:
|
Additionally, I'd be open to a PR that just removes the location information when printing without source. I think it's strictly worse to include misleading information than no information. |
Summary: 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) Pull Request resolved: #4574 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`. Reviewed By: alunyov Differential Revision: D52663262 Pulled By: captbaritone fbshipit-source-id: e2fcf98a3ace0a83aa73b2eaabeea10d1958b455
When running the relay compiler with errors, theres a few problems with the outputted erroring filepaths. They are not critical or "wrong", but cause inconvenience when attempting to open the problematic line (especially in vscode). Here's an example output:
<path>:<linenumber>:<character_index_within_line>
. I'm not sure how standard this format is, but it would be very convenient within vscode at least to adopt this format.The text was updated successfully, but these errors were encountered: