diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-05 05:56:16 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-07 02:09:01 +0300 |
commit | 66d41d2c22ca949cb1877818b923109c914dffa9 (patch) | |
tree | 8098786d2caaba7b86565ff1465c780fd3f4d4c4 /lib/gitlab/ci | |
parent | cf887a8b3108edb715ee5618377f4ffab1824d85 (diff) |
Handle all YAML parser exceptions in .gitlab-ci.yml (fixes #41209)
- Move the exception handling as close to the source as possible to
avoid leaking Psych ahstraction
- Also remove unnecessary rescue all statement from LintsController.
This should not be necessary anymore since any YAML errors should all be
caught by the #validation_message method.
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r-- | lib/gitlab/ci/config/loader.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/gitlab/ci/config/loader.rb b/lib/gitlab/ci/config/loader.rb index e7d9f6a7761..141d2714cb6 100644 --- a/lib/gitlab/ci/config/loader.rb +++ b/lib/gitlab/ci/config/loader.rb @@ -6,6 +6,8 @@ module Gitlab def initialize(config) @config = YAML.safe_load(config, [Symbol], [], true) + rescue Psych::Exception => e + raise FormatError, e.message end def valid? diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 0bd78b03448..a7285ac8f9d 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -85,7 +85,7 @@ module Gitlab begin Gitlab::Ci::YamlProcessor.new(content) nil - rescue ValidationError, Psych::SyntaxError => e + rescue ValidationError => e e.message end end |