daneden / Zeitgeist

👁 An iOS app for keeping an eye on your Vercel deployments
http://zeitgeist.daneden.me
Apache License 2.0
190 stars 7 forks source link

Add missing standard deployment protection key #97

Closed bdbergeron closed 9 months ago

bdbergeron commented 10 months ago

Like many other users, my projects have disappeared from the Zeitgeist app recently. All of my projects have Deployment Protection setup to require Vercel authorization to preview deployments and any other domains except the most recent production deployment, which in Vercel parlance is "Standard Protection."

The DeploymentTypeProtection enum currently only handles preview and all values for the API response, resulting in a decoding failure if a user has Standard Protection enabled on any of their projects. This PR adds support for the new value returned by the Vercel API for projects with Standard Protection enabled.

bdbergeron commented 10 months ago

This will likely help to resolve #85, #94, #95, and #96.

bdbergeron commented 10 months ago

Considering how many enum types are being used in the codebase and their inherent instability with Apple's Decodable parsing, you may want to consider adopting a library like airbnb/ResilientDecoding to help prevent issues like this from arising again in the future. Simply using the @Resilient property wrapper on a variable referencing an optional enum type ensures that a decoding failure will fallback to the variable being nil.

import ResilientDecoding

extension VercelProject {
  struct ProtectionSettings: Decodable {
    @Resilient var deploymentType: DeploymentTypeProtection?
  }
}

enum DeploymentTypeProtection: String, Decodable {
  case standard = "prod_deployment_urls_and_all_previews"
  case preview
  case all
}

With that in place, if the Vercel API ever changes an existing or adds a new Deployment Protection type value, the decoding will no longer fail but instead simply set ProtectionSettings.deploymentType = nil.

bdbergeron commented 9 months ago

Hey @daneden, any chance you can take a quick look at this and get a build to the App Store with this fix? Thanks!

daneden commented 9 months ago
loganbek commented 9 months ago

@daneden @bdbergeron Is there anything I can do to help get this across the finish line?

daneden commented 9 months ago

@loganbek @bdbergeron unfortunately I’m now experiencing an issue with Xcode related to provisioning profiles and code signing. I’m in touch with Apple Developer Support to try and fix the issue, which is preventing upload of the new build to App Store Connect.

daneden commented 9 months ago

This fix is now shipped in v3.2.1. I’ve actually also got a change ready for 3.2.2 that fixes this issue another way: by removing the deployment protection key from the structure. That key, along with about a dozen others, wasn't actually used anywhere in the app. I'd encountered a similar decoding issue with Node versions, which, again, I had used an enum for and, again, wasn't actually used anywhere.

Appreciate the tip about ResilientDecoding, @bdbergeron; I may well reach for it in a future release!