Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(flags): is_5xx cleanup (#59025)

Matheus Batista9fc56e24a6c8
diff --git a/rust/feature-flags/src/api/errors.rs b/rust/feature-flags/src/api/errors.rs
index 464036f35082..9cc2923240b0 100644
--- a/rust/feature-flags/src/api/errors.rs
+++ b/rust/feature-flags/src/api/errors.rs
@@ -316,48 +316,7 @@ impl FlagError {
}
pub fn is_5xx(&self) -> bool {
- let status = match self {
- FlagError::ClientFacing(ClientFacingError::ServiceUnavailable) => {
- StatusCode::SERVICE_UNAVAILABLE
- }
- FlagError::ClientFacing(_) => return false, // All other ClientFacing are 4XX
- FlagError::Internal(_)
- | FlagError::DeserializeFiltersError
- | FlagError::DatabaseError(_, _)
- | FlagError::NoGroupTypeMappings
- | FlagError::GroupTypeMappingFetchFailed
- | FlagError::RowNotFound
- | FlagError::DependencyNotFound(_, _)
- | FlagError::CohortFiltersParsingError
- | FlagError::DependencyCycle(_, _)
- | FlagError::DataParsingError
- | FlagError::BatchEvaluationPanicked
- | FlagError::DataParsingErrorWithContext(_)
- | FlagError::HashKeyOverrideError => StatusCode::INTERNAL_SERVER_ERROR,
-
- FlagError::RayonSemaphoreTimeout(_) => StatusCode::GATEWAY_TIMEOUT,
-
- FlagError::RedisUnavailable
- | FlagError::DatabaseUnavailable
- | FlagError::TimeoutError(_)
- | FlagError::CacheMiss
- | FlagError::PersonNotFound
- | FlagError::PropertiesNotInCache
- | FlagError::StaticCohortMatchesNotCached => StatusCode::SERVICE_UNAVAILABLE,
-
- FlagError::CookielessError(
- CookielessManagerError::HashError(_)
- | CookielessManagerError::ChronoError(_)
- | CookielessManagerError::RedisError(_, _)
- | CookielessManagerError::SaltCacheError(
- SaltCacheError::RedisError(_) | SaltCacheError::SaltRetrievalFailed,
- )
- | CookielessManagerError::InvalidIdentifyCount(_),
- ) => StatusCode::INTERNAL_SERVER_ERROR,
- FlagError::CookielessError(_) => return false, // Other CookielessErrors are 4XX
- _ => return false, // Everything else is 4XX
- };
- status.is_server_error()
+ self.status_code() >= 500
}
}