PRX / feeder.prx.org

Dovetail podcast content management system
https://podcasts.dovetail.prx.org
GNU Affero General Public License v3.0
5 stars 0 forks source link

Apple episodes not yet synced to the public feed can have updates #1014

Closed kookster closed 2 months ago

kookster commented 3 months ago

Had a weird problem with a SJ episode - it was created in Apple, but had empty title and description. That shouldn't happen - those fields should have values by the time we're publishing and then publishing to Apple. But, somehow it did, but then there were no calls to Apple::Episode.update_episodes, so the attributes stayed blank.

So, while we try to figure out the mechanism that an invalid episode got created, we can change the episode sync to update episodes that are still DRAFTING publish state in Apple, which should be prior to sync with the public episode that locks down updates.

When this happened, attempts to publish the episode failed with this info:

Error message:
[
  {
      "request_metadata": {
          "apple_episode_id": "1000654364957"
      },
      "api_parameters": {
          "data": {
              "type": "episodePublishingRequests",
              "attributes": {
                  "action": "PUBLISH"
              },
              "relationships": {
                  "episode": {
                      "data": {
                          "id": "1000654364957",
                          "type": "episodes"
                      }
                  }
              }
          }
      },
      "api_url": "https://api.podcastsconnect.apple.com/v1/episodePublishingRequests",
      "api_response": {
          "ok": false,
          "err": true,
          "val": {
              "data": {
                  "body": {
                      "errors": [
                          {
                              "id": "a61ebc06-d92b-4b00-a894-7a00b2cd01ac",
                              "status": "409",
                              "code": "ENTITY_ERROR.ATTRIBUTE.INVALID",
                              "title": "The provided entity includes an attribute with an invalid value",
                              "detail": "Should be non-null, non-empty, and no longer than 150 characters",
                              "source": {
                                  "pointer": "/data/attributes/title"
                              }
                          },
                          {
                              "id": "52dad9d5-48c2-4e2e-b4be-ebb67d072e2b",
                              "status": "409",
                              "code": "ENTITY_ERROR.ATTRIBUTE.INVALID",
                              "title": "The provided entity includes an attribute with an invalid value",
                              "detail": "Should be non-null, non-empty, and no longer than 4000 characters",
                              "source": {
                                  "pointer": "/data/attributes/description"
                              }
                          },
                          {
                              "id": "0ddcb670-f05c-4daf-8c9f-2b59eda2f448",
                              "status": "409",
                              "code": "ENTITY_ERROR.ATTRIBUTE.INVALID",
                              "title": "The provided entity includes an attribute with an invalid value",
                              "detail": "originalReleaseDate should be present and non-null",
                              "source": {
                                  "pointer": "/data/attributes/originalReleaseDate"
                              }
                          }
                      ]
                  },
                  "status": 409,
                  "context": "response"
              }
          },
          "_stack": " at formatApiError (file:///var/task/api_response.js:36:12)\n at file:///var/task/api.js:156:46\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
      }
  }
]
                                 /app/app/models/apple/api.rb:276:in `raise_bridge_api_error'
                                 /app/app/models/apple/api.rb:270:in `bridge_remote_and_retry!'
                             /app/app/models/apple/episode.rb:179:in `alter_publish_state'
                             /app/app/models/apple/episode.rb:173:in `publish'
                           /app/app/models/apple/publisher.rb:359:in `block in publish_drafting!'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:99:in `block in tagged'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:37:in `tagged'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:99:in `tagged'
                           /app/app/models/apple/publisher.rb:356:in `publish_drafting!'
                           /app/app/models/apple/publisher.rb:153:in `block(2 levels) in deliver_and_publish!'
                           /app/app/models/apple/publisher.rb:133:in `each'
                           /app/app/models/apple/publisher.rb:133:in `each_slice'
                           /app/app/models/apple/publisher.rb:133:in `block in deliver_and_publish!'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:99:in `block in tagged'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:37:in `tagged'
…s/activesupport-7.0.8.1/lib/active_support/tagged_logging.rb:99:in `tagged'
                           /app/app/models/apple/publisher.rb:132:in `deliver_and_publish!'
                           /app/app/models/apple/publisher.rb:125:in `publish!'
                           /app/app/jobs/publish_apple_job.rb:5:in `publish_to_apple'
                           /app/app/jobs/publish_apple_job.rb:14:in `perform'
kookster commented 2 months ago

fixed by #1015