Skip to content

Commit 4327cf2

Browse files
authored
Merge pull request #9054 from AriaXLi/PUP-11785/do_not_fallback_to_pson_in_main
(PUP-11785) Don't fallback to PSON if catalog rendering fails
2 parents 5a43845 + 3dd7cd5 commit 4327cf2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/puppet/defaults.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ def self.initialize_default_settings!(settings)
17181718
}
17191719
},
17201720
:allow_pson_serialization => {
1721-
:default => true,
1721+
:default => false,
17221722
:type => :boolean,
17231723
:desc => "Whether when unable to serialize to JSON or other formats,
17241724
Puppet falls back to PSON. This option affects both puppetserver's

spec/unit/network/http/api/indirected_routes_spec.rb

+6-7
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
end
179179

180180
it "falls back to the next supported format", if: Puppet.features.pson? do
181+
Puppet[:allow_pson_serialization] = true
181182
data = Puppet::IndirectorTesting.new("my data")
182183
indirection.save(data, "my data")
183184
request = a_request_that_finds(data, :accept_header => "application/json, text/pson")
@@ -211,8 +212,7 @@
211212
}.to raise_error(not_found_error)
212213
end
213214

214-
it "should raise FormatError if tries to fallback and pson serialization is not allowed" do
215-
Puppet[:allow_pson_serialization] = false
215+
it "should raise FormatError if tries to fallback" do
216216
data = Puppet::IndirectorTesting.new("my data")
217217
indirection.save(data, "my data")
218218
request = a_request_that_finds(data, :accept_header => "unknown, text/pson")
@@ -239,6 +239,7 @@
239239
end
240240

241241
it "falls back to the next supported format", if: Puppet.features.pson? do
242+
Puppet[:allow_pson_serialization] = true
242243
data = Puppet::IndirectorTesting.new("my data")
243244
indirection.save(data, "my data")
244245
request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "application/json, text/pson")
@@ -254,17 +255,15 @@
254255
it "raises 406 not acceptable if no formats are accceptable" do
255256
data = Puppet::IndirectorTesting.new("my data")
256257
indirection.save(data, "my data")
257-
request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "application/json")
258-
allow(data).to receive(:to_json).and_raise(Puppet::Network::FormatHandler::FormatError, 'Could not render to Puppet::Network::Format[json]: source sequence is illegal/malformed utf-8')
258+
request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "unknown")
259259

260260
expect {
261261
handler.call(request, response)
262262
}.to raise_error(Puppet::Network::HTTP::Error::HTTPNotAcceptableError,
263-
%r{No supported formats are acceptable \(Accept: application/json\)})
263+
%r{No supported formats are acceptable \(Accept: unknown\)})
264264
end
265265

266-
it "raises FormatError if tries to fallback and pson serialization is not allowed" do
267-
Puppet[:allow_pson_serialization] = false
266+
it "raises FormatError if tries to fallback" do
268267
data = Puppet::IndirectorTesting.new("my data")
269268
indirection.save(data, "my data")
270269
request = a_request_that_searches(Puppet::IndirectorTesting.new("my"), :accept_header => "unknown, text/pson")

0 commit comments

Comments
 (0)