Skip to content

Commit 95520f8

Browse files
committed
feat: Show config file name in validation messages
Interpolate the config file name in the validation messages. This allows them to be displayed directly to the user, without requiring any additional processing.
1 parent 7e81d35 commit 95520f8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/appmap/service/validator/config_validator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def parse_config
3939
rescue Psych::SyntaxError => e
4040
@violations << Violation.error(
4141
filename: @config_file,
42-
message: 'AppMap configuration is not valid YAML',
42+
message: "AppMap configuration #{@config_file} is not valid YAML",
4343
detailed_message: e.message
4444
)
4545
nil
@@ -52,7 +52,7 @@ def validate_config_load
5252
rescue StandardError => e
5353
@violations << Violation.error(
5454
filename: @config_file,
55-
message: 'AppMap configuration could not be loaded',
55+
message: "AppMap configuration #{@config_file} could not be loaded",
5656
detailed_message: e.message
5757
)
5858
nil
@@ -62,7 +62,7 @@ def validate_config_presence
6262
unless present?
6363
@violations << Violation.error(
6464
filename: @config_file,
65-
message: 'AppMap configuration file does not exist'
65+
message: "AppMap configuration #{@config_file} file does not exist"
6666
)
6767
end
6868
end

test/agent_setup_validate_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_init_with_non_existing_config_file
3030
{
3131
level: :error,
3232
filename: NON_EXISTING_CONFIG_FILENAME,
33-
message: 'AppMap configuration file does not exist'
33+
message: "AppMap configuration #{NON_EXISTING_CONFIG_FILENAME} file does not exist"
3434
}
3535
])
3636
assert_equal expected, output.strip
@@ -47,7 +47,7 @@ def test_init_with_invalid_YAML
4747
{
4848
level: :error,
4949
filename: INVALID_YAML_CONFIG_FILENAME,
50-
message: 'AppMap configuration is not valid YAML',
50+
message: "AppMap configuration #{INVALID_YAML_CONFIG_FILENAME} is not valid YAML",
5151
detailed_message: "(#{INVALID_YAML_CONFIG_FILENAME}): " \
5252
'did not find expected key while parsing a block mapping at line 1 column 1'
5353
}
@@ -66,7 +66,7 @@ def test_init_with_invalid_data_config
6666
{
6767
level: :error,
6868
filename: INVALID_CONFIG_FILENAME,
69-
message: 'AppMap configuration could not be loaded',
69+
message: "AppMap configuration #{INVALID_CONFIG_FILENAME} could not be loaded",
7070
detailed_message: "no implicit conversion of String into Integer"
7171
}
7272
])

0 commit comments

Comments
 (0)