From 2571b8fd5482059844f8b3311127f52f85184f57 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 5 Jun 2026 16:37:29 -0700 Subject: [PATCH 1/2] Show config help hint on config parse errors When the compiler fails to parse or validate the config file, append a hint pointing users to the `config-json-schema` CLI subcommand and the config documentation page on relay.dev. --- compiler/crates/relay-bin/src/errors.rs | 3 +++ compiler/crates/relay-bin/src/main.rs | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/compiler/crates/relay-bin/src/errors.rs b/compiler/crates/relay-bin/src/errors.rs index 7aa20884f1710..fb10750147154 100644 --- a/compiler/crates/relay-bin/src/errors.rs +++ b/compiler/crates/relay-bin/src/errors.rs @@ -18,6 +18,9 @@ pub enum Error { #[error("{0}")] ConfigError(relay_compiler::errors::Error), + #[error("{source}\n\nHint: You can dump the config JSON schema with:\n relay-compiler config-json-schema\n\nFor documentation, see:\n https://relay.dev/docs/getting-started/compiler-config/")] + ConfigErrorWithHint { source: Box }, + #[error("Unable to run relay compiler. Error details: \n{details}")] CompilerError { details: String }, diff --git a/compiler/crates/relay-bin/src/main.rs b/compiler/crates/relay-bin/src/main.rs index 0468c648409f2..7e6a9936c5dbc 100644 --- a/compiler/crates/relay-bin/src/main.rs +++ b/compiler/crates/relay-bin/src/main.rs @@ -278,11 +278,23 @@ async fn main() { } fn get_config(config_path: Option) -> Result { - match config_path { - Some(config_path) => Config::load(config_path).map_err(Error::ConfigError), - None => Config::search(¤t_dir().expect("Unable to get current working directory.")) - .map_err(Error::ConfigError), - } + let result = match config_path { + Some(config_path) => Config::load(config_path), + None => Config::search(¤t_dir().expect("Unable to get current working directory.")), + }; + result.map_err(|err| { + let is_config_error = matches!( + err, + CompilerError::ConfigError { .. } | CompilerError::ConfigFileValidation { .. } + ); + let mut err = Error::ConfigError(err); + if is_config_error { + err = Error::ConfigErrorWithHint { + source: Box::new(err), + }; + } + err + }) } fn configure_logger(output: OutputKind, terminal_mode: TerminalMode) { From a7f18272f56d49c6912d2c46919f3e5ac4d3cf74 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 5 Jun 2026 16:46:25 -0700 Subject: [PATCH 2/2] Fix rustfmt: break long error attribute onto multiple lines --- compiler/crates/relay-bin/src/errors.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/crates/relay-bin/src/errors.rs b/compiler/crates/relay-bin/src/errors.rs index fb10750147154..7fa03ad88dbea 100644 --- a/compiler/crates/relay-bin/src/errors.rs +++ b/compiler/crates/relay-bin/src/errors.rs @@ -18,7 +18,9 @@ pub enum Error { #[error("{0}")] ConfigError(relay_compiler::errors::Error), - #[error("{source}\n\nHint: You can dump the config JSON schema with:\n relay-compiler config-json-schema\n\nFor documentation, see:\n https://relay.dev/docs/getting-started/compiler-config/")] + #[error( + "{source}\n\nHint: You can dump the config JSON schema with:\n relay-compiler config-json-schema\n\nFor documentation, see:\n https://relay.dev/docs/getting-started/compiler-config/" + )] ConfigErrorWithHint { source: Box }, #[error("Unable to run relay compiler. Error details: \n{details}")]