Skip to content

Commit

Permalink
tasks(repackage_boshreleases_fallback): fix deserialization
Browse files Browse the repository at this point in the history
As of Ruby 3.1, if you use YAML.load_file, you must explicitly list the classes that are allowed for deserialization.
Otherwise, a `Psych::DisallowedClass` error will be thrown.
  • Loading branch information
o-orand committed Mar 19, 2024
1 parent 33dffc3 commit 18ee75a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RepackageReleasesFallback

def initialize(repackaged_error_filepath = "")
@repackaged_errors = if File.exist?(repackaged_error_filepath)
YAML.load_file(repackaged_error_filepath, aliases: true) || {}
YAML.load_file(repackaged_error_filepath, aliases: true, permitted_classes: [Tasks::Bosh::BoshCliError]) || {}
else
{}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
Bosh director: !ruby/exception:Tasks::Bosh::BoshCliError
message: |-
Stderr:
Stdout:
{
"Tables": null,
"Blocks": null,
"Lines": [
"Fetching info:\n Performing request GET 'https://192.168.116.158:25555/info':\n Performing GET request:\n Retry: Get \"https://192.168.116.158:25555/info\": dial tcp 192.168.116.158:25555: connect: connection refused",
"Exit code 1"
]
}
backtrace:
- "/tmp/build/22f65861/cf-ops-automation/lib/tasks/bosh/executor.rb:39:in `handle_bosh_cli_response'"
- "/tmp/build/22f65861/cf-ops-automation/lib/tasks/bosh/executor.rb:34:in `run_command'"
- "/tmp/build/22f65861/cf-ops-automation/lib/tasks/bosh/list_releases.rb:7:in `execute'"
- "/tmp/build/22f65861/cf-ops-automation/concourse/tasks/repackage_boshreleases/repackage_releases.rb:133:in `filter_releases'"
- "/tmp/build/22f65861/cf-ops-automation/concourse/tasks/repackage_boshreleases/repackage_releases.rb:32:in `process'"
- cf-ops-automation/concourse/tasks/repackage_boshreleases/run.rb:42:in `<main>'
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
context "when errors file contains errors" do
let(:repackaged_releases_path) { File.join(basedir, 'download_failures') }

it "creates an object with errors" do
expect(repackage_releases_fallback.has_errors?).to be_truthy
end
end

context "when bosh returns an errors" do
let(:repackaged_releases_path) { File.join(basedir, 'bosh_connection_refused') }

it "creates an object with errors" do
expect(repackage_releases_fallback.has_errors?).to be_truthy
end
Expand Down

0 comments on commit 18ee75a

Please sign in to comment.