-
Task
-
Resolution: Unresolved
-
Major
-
None
-
None
-
False
-
None
-
False
-
Not Started
-
Not Started
-
Not Started
-
Not Started
-
Not Started
-
Not Started
-
-
In Proxy::PoliciesConfig we override ::name method to return just `PoliciesConfig` instead of `Proxy::PoliciesConfig` probably to have representers happy. See
https://github.com/3scale/porta/blob/962e945968721331c5f1d5d9211c95286537067e/app/models/proxy.rb#L564-L566
https://github.com/3scale/system/commit/f06e18e4d05
This breaks serialization and deserialization for example with YAML:
[1] pry(main)> pc = Proxy.last.policies_config => #<Proxy::PoliciesConfig:0x000000000d074358 @policies_config= [#<Proxy::PolicyConfig:0x000000000d07be50 @configuration={}, @enabled=true, @name="apicast", @version="builtin">, #<Proxy::PolicyConfig:0x000000000d07be00 @configuration={}, @enabled=true, @name="3scale_referrer", @version="builtin">]> [2] pry(main)> ser = pc.to_yaml => "--- !ruby/object:PoliciesConfig\npolicies_config:\n- !ruby/object:Proxy::PolicyConfig\n name: apicast\n version: builtin\n configuration: {}\n enabled: true\n- !ruby/object:Proxy::PolicyConfig\n name: 3scale_referrer\n version: builtin\n configuration: {}\n enabled: true\n" [3] pry(main)> YAML.load ser ArgumentError: undefined class/module PoliciesConfig from /home/avalon/.asdf/installs/ruby/2.6.7/lib/ruby/2.6.0/psych/class_loader.rb:54:in `path2class' Caused by ArgumentError: undefined class/module Struct::PoliciesConfig from /home/avalon/.asdf/installs/ruby/2.6.7/lib/ruby/2.6.0/psych/class_loader.rb:54:in `path2class'
This breaks audited to work with Proxy: https://github.com/3scale/porta/pull/3226
And is in general fragile to override methods of a very base class. We better see how to make representers happy without this:
- extract the class out of Proxy or
- edit representers to hardcode what we need there