Skip to content

Commit a01431e

Browse files
committed
Remove duplicate mapping key
The error codes `60003` and `290013` appear twice. While many YAML parsers can cope with duplicate mapping keys, many parser will error out. External tools, like for example [go-cfclient's gen_error.go](https://github.com/cloudfoundry/go-cfclient/blob/main/tools/gen_error.go), cannot update to more recent major versions of their YAML parser library: ```shell yaml: unmarshal errors: line 221: mapping key "60003" already defined at line 216 line 1036: mapping key "290013" already defined at line 1026 panic: yaml: unmarshal errors: line 221: mapping key "60003" already defined at line 216 line 1036: mapping key "290013" already defined at line 1026 ``` Cloud Controller uses `psych` to parse the errors/*.yml files. Psych uses the latest occurence of a key. Therefore, the most recent duplicate key can be picked to stay in the errors files. ``` irb(main):001> require 'psych' => true irb(main):002> filepath = "errors/v2.yml" => "errors/v2.yml" irb(main):003* content = File.open(filepath) do |f| irb(main):004* Psych.safe_load(f, strict_integer: true) irb(main):005> end; nil => nil irb(main):006> content[60003] => {"name"=>"ServiceInstanceInvalid", "http_code"=>400, "message"=>"The service instance is invalid: %s"} irb(main):007> content[290013] => {"name"=>"SpaceRolesDeletionTimeout", "http_code"=>524, "message"=>"Deletion of roles for space %s timed out before all roles could be deleted"} ```
1 parent 03897ff commit a01431e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

Diff for: errors/v2.yml

+2-12
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@
213213
http_code: 400
214214
message: "The service instance name is taken: %s"
215215

216-
60003:
217-
name: ServiceInstanceServiceBindingWrongSpace
218-
http_code: 400
219-
message: "The service instance and the service binding are in different app spaces: %s"
220-
221216
60003:
222217
name: ServiceInstanceInvalid
223218
http_code: 400
@@ -1024,20 +1019,15 @@
10241019
message: "Resource inside space %s must first be deleted, or specify recursive delete."
10251020

10261021
290013:
1027-
name: OrganizationRolesDeletionTimeout
1022+
name: SpaceRolesDeletionTimeout
10281023
http_code: 524
1029-
message: "Deletion of roles for organization %s timed out before all roles could be deleted"
1024+
message: "Deletion of roles for space %s timed out before all roles could be deleted"
10301025

10311026
290014:
10321027
name: OrganizationRolesDeletionFailed
10331028
http_code: 502
10341029
message: "Failed to delete one or more roles for organization %s"
10351030

1036-
290013:
1037-
name: SpaceRolesDeletionTimeout
1038-
http_code: 524
1039-
message: "Deletion of roles for space %s timed out before all roles could be deleted"
1040-
10411031
290016:
10421032
name: SpaceRolesDeletionFailed
10431033
http_code: 502

0 commit comments

Comments
 (0)