facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
204 stars 161 forks source link

Field specified more than once #113

Open apa512 opened 3 years ago

apa512 commented 3 years ago

Which SDK version are you using?

0.8.0.0

What's the issue?

Many different operations lead to an object with some kind of messed up state.

Steps/Sample code to reproduce the issue

ad = FacebookAds::Ad.get("123", session)
ad.status = "ACTIVE"
ad.save
ad.status

Observed Results:

FacebookAds::ClientError (Syntax error "Field status specified more than once. This is only possible before version 2.1" at character 34: id,configured_status,status,status:  (fbtrace_id: hidden))

Expected Results:

I expect to see "ACTIVE".

Any idea what I'm doing wrong?

ericzou commented 3 years ago

same issue here for attribution_spec. looks like adset.__all_fields contains both symbol and strings for the same key after save.. e.g. #<Set: {:id, :attribution_spec, :name, "attribution_spec"}>

ericzou commented 3 years ago

dug a bit more. it seems that the following line is converting the symbol to string.

      def define_writer(name)
        define_method("#{name}=") do |val|
          changes[name] = val
          @__all_fields.add(name.to_s) <--- 
        end
      end
stale[bot] commented 2 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

peylun commented 1 year ago

👋 Any update on this issue? I am encountering the same error when trying to save values on different level objects. Oddly even though it returns error on save, the value managed to get persisted; occasionally it manages to save successfully, but accessing the value after reload! returns the same error.

Examples