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): remove dead FlagError variants (#61000)

Phil Haack5a4434127adb
diff --git a/rust/feature-flags/src/api/errors.rs b/rust/feature-flags/src/api/errors.rs
index 9cc2923240b0..33af43fc5bee 100644
--- a/rust/feature-flags/src/api/errors.rs
+++ b/rust/feature-flags/src/api/errors.rs
@@ -83,8 +83,6 @@ pub enum FlagError {
/// not a service availability issue.
#[error("Failed to parse flag data: {0}")]
DataParsingErrorWithContext(String),
- #[error("failed to deserialize filters")]
- DeserializeFiltersError,
#[error("redis unavailable")]
RedisUnavailable,
#[error("database unavailable")]
@@ -109,10 +107,6 @@ pub enum FlagError {
/// - `None` - Timeout occurred but specific type unknown
#[error("Timed out while fetching data")]
TimeoutError(Option<String>),
- #[error("No group type mappings")]
- NoGroupTypeMappings,
- #[error("Failed to fetch group type mappings from database")]
- GroupTypeMappingFetchFailed,
#[error("Dependency of type {0} with id {1} not found")]
DependencyNotFound(DependencyType, i64),
#[error("Failed to parse cohort filters")]
@@ -121,10 +115,6 @@ pub enum FlagError {
DependencyCycle(DependencyType, i64),
#[error("Person not found")]
PersonNotFound,
- #[error("Person properties not found")]
- PropertiesNotInCache,
- #[error("Static cohort matches not cached")]
- StaticCohortMatchesNotCached,
#[error("Cache miss - data not found in cache")]
CacheMiss,
#[error("Failed to parse data")]
@@ -176,10 +166,7 @@ impl FlagError {
// Internal server errors (500)
FlagError::Internal(_) => ("internal_error", 500),
- FlagError::DeserializeFiltersError => ("deserialize_filters_error", 500),
FlagError::DatabaseError(_, _) => ("database_error", 500),
- FlagError::NoGroupTypeMappings => ("no_group_type_mappings", 500),
- FlagError::GroupTypeMappingFetchFailed => ("group_type_mapping_fetch_failed", 500),
FlagError::RowNotFound => ("row_not_found", 500),
FlagError::DependencyNotFound(_, _) => ("dependency_not_found", 500),
FlagError::CohortFiltersParsingError => ("cohort_filters_parsing_error", 500),
@@ -199,8 +186,6 @@ impl FlagError {
FlagError::CacheMiss => ("cache_miss", 503),
// Cache misses for person/cohort data - transient, data may be populated soon
FlagError::PersonNotFound => ("person_not_found", 503),
- FlagError::PropertiesNotInCache => ("properties_not_in_cache", 503),
- FlagError::StaticCohortMatchesNotCached => ("static_cohort_not_cached", 503),
// Cookieless errors (mixed)
FlagError::CookielessError(err) => match err {
@@ -423,13 +408,6 @@ impl IntoResponse for FlagError {
"Failed to parse flag configuration data. This may indicate a misconfigured feature flag. Please check your flag definitions or contact support.".to_string(),
)
}
- FlagError::DeserializeFiltersError => {
- tracing::error!("Failed to deserialize filters");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "Failed to deserialize property filters. This is likely a temporary issue. Please try again later.".to_string(),
- )
- }
FlagError::RedisUnavailable => {
tracing::error!("Redis unavailable: {:?}", self);
(
@@ -463,20 +441,6 @@ impl IntoResponse for FlagError {
"The request timed out. This could be due to high load or network issues. Please try again later.".to_string(),
)
}
- FlagError::NoGroupTypeMappings => {
- tracing::error!("No group type mappings: {:?}", self);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "No group type mappings found. This is likely a configuration issue. Please contact support.".to_string(),
- )
- }
- FlagError::GroupTypeMappingFetchFailed => {
- tracing::error!("Failed to fetch group type mappings: {:?}", self);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "Failed to fetch group type mappings from database.".to_string(),
- )
- }
FlagError::RowNotFound => {
tracing::error!("Row not found in postgres: {:?}", self);
(
@@ -504,14 +468,6 @@ impl IntoResponse for FlagError {
tracing::warn!("Person not found in cache");
(StatusCode::SERVICE_UNAVAILABLE, "Person data not yet available. This is a temporary issue while data is being populated. Please try again.".to_string())
}
- FlagError::PropertiesNotInCache => {
- tracing::warn!("Person properties not found in cache");
- (StatusCode::SERVICE_UNAVAILABLE, "Person properties not yet available. This is a temporary issue while data is being populated. Please try again.".to_string())
- }
- FlagError::StaticCohortMatchesNotCached => {
- tracing::warn!("Static cohort matches not found in cache");
- (StatusCode::SERVICE_UNAVAILABLE, "Cohort membership data not yet available. This is a temporary issue while data is being populated. Please try again.".to_string())
- }
FlagError::CacheMiss => {
tracing::error!("Cache miss - required data not found in cache");
(StatusCode::SERVICE_UNAVAILABLE, "Required data not found in cache. This is likely a temporary issue. Please try again later.".to_string())
@@ -815,22 +771,18 @@ mod tests {
FlagError::NoAuthenticationProvided,
FlagError::RowNotFound,
FlagError::DataParsingErrorWithContext("test parse error".to_string()),
- FlagError::DeserializeFiltersError,
FlagError::RedisUnavailable,
FlagError::DatabaseUnavailable,
FlagError::DatabaseError(sqlx::Error::RowNotFound, Some("test context".to_string())),
FlagError::TimeoutError(None),
- FlagError::NoGroupTypeMappings,
- FlagError::GroupTypeMappingFetchFailed,
FlagError::DependencyNotFound(DependencyType::Flag, 1),
FlagError::DependencyCycle(DependencyType::Cohort, 2),
FlagError::CohortFiltersParsingError,
FlagError::PersonNotFound,
- FlagError::PropertiesNotInCache,
- FlagError::StaticCohortMatchesNotCached,
FlagError::CacheMiss,
FlagError::DataParsingError,
FlagError::BatchEvaluationPanicked,
+ FlagError::HashKeyOverrideError,
FlagError::RayonSemaphoreTimeout(800),
CookielessManagerError::MissingProperty("test".to_string()).into(), // CookielessError
];
@@ -891,8 +843,6 @@ mod tests {
assert_eq!(FlagError::RowNotFound.status_code(), 500);
// Cache miss errors are now 503 (transient)
assert_eq!(FlagError::PersonNotFound.status_code(), 503);
- assert_eq!(FlagError::PropertiesNotInCache.status_code(), 503);
- assert_eq!(FlagError::StaticCohortMatchesNotCached.status_code(), 503);
// Semaphore timeout is 504 (gateway timeout for ingress retry)
assert_eq!(FlagError::RayonSemaphoreTimeout(800).status_code(), 504);
}
@@ -917,9 +867,6 @@ mod tests {
// Server errors should be 5xx
let server_errors = vec![
FlagError::Internal("".into()),
- FlagError::DeserializeFiltersError,
- FlagError::NoGroupTypeMappings,
- FlagError::GroupTypeMappingFetchFailed,
FlagError::RowNotFound,
FlagError::CohortFiltersParsingError,
FlagError::DataParsingError,
@@ -935,16 +882,14 @@ mod tests {
// Verify that status_code() >= 500 matches is_5xx() for ALL 5xx errors
let errors_5xx = vec![
FlagError::Internal("test".to_string()),
- FlagError::DeserializeFiltersError,
FlagError::DatabaseError(sqlx::Error::RowNotFound, None),
- FlagError::NoGroupTypeMappings,
- FlagError::GroupTypeMappingFetchFailed,
FlagError::RowNotFound,
FlagError::DependencyNotFound(DependencyType::Flag, 1),
FlagError::CohortFiltersParsingError,
FlagError::DependencyCycle(DependencyType::Cohort, 2),
FlagError::DataParsingError,
FlagError::BatchEvaluationPanicked,
+ FlagError::HashKeyOverrideError,
FlagError::RayonSemaphoreTimeout(800),
FlagError::DataParsingErrorWithContext("test".to_string()),
FlagError::RedisUnavailable,
@@ -952,8 +897,6 @@ mod tests {
FlagError::TimeoutError(None),
FlagError::CacheMiss,
FlagError::PersonNotFound,
- FlagError::PropertiesNotInCache,
- FlagError::StaticCohortMatchesNotCached,
FlagError::ClientFacing(ClientFacingError::ServiceUnavailable),
];
@@ -1049,21 +992,18 @@ mod tests {
FlagError::NoAuthenticationProvided,
FlagError::RowNotFound,
FlagError::DataParsingErrorWithContext("test parse error".to_string()),
- FlagError::DeserializeFiltersError,
FlagError::RedisUnavailable,
FlagError::DatabaseUnavailable,
FlagError::DatabaseError(sqlx::Error::RowNotFound, Some("test context".to_string())),
FlagError::TimeoutError(None),
- FlagError::NoGroupTypeMappings,
FlagError::DependencyNotFound(DependencyType::Flag, 1),
FlagError::DependencyCycle(DependencyType::Cohort, 2),
FlagError::CohortFiltersParsingError,
FlagError::PersonNotFound,
- FlagError::PropertiesNotInCache,
- FlagError::StaticCohortMatchesNotCached,
FlagError::CacheMiss,
FlagError::DataParsingError,
FlagError::BatchEvaluationPanicked,
+ FlagError::HashKeyOverrideError,
FlagError::RayonSemaphoreTimeout(800),
CookielessManagerError::MissingProperty("test".to_string()).into(),
];
diff --git a/rust/feature-flags/src/handler/canonical_log.rs b/rust/feature-flags/src/handler/canonical_log.rs
index 0d7869a27a06..15b877ec39d2 100644
--- a/rust/feature-flags/src/handler/canonical_log.rs
+++ b/rust/feature-flags/src/handler/canonical_log.rs
@@ -1212,12 +1212,10 @@ mod tests {
#[case(FlagError::NoAuthenticationProvided, 401, "no_authentication")]
#[case(FlagError::RowNotFound, 500, "row_not_found")]
#[case(FlagError::DataParsingErrorWithContext("test".into()), 500, "flag_data_parsing_error")]
- #[case(FlagError::DeserializeFiltersError, 500, "deserialize_filters_error")]
#[case(FlagError::RedisUnavailable, 503, "redis_unavailable")]
#[case(FlagError::DatabaseUnavailable, 503, "database_unavailable")]
#[case(FlagError::TimeoutError(None), 503, "timeout")]
#[case(FlagError::TimeoutError(Some("pool".into())), 503, "timeout")]
- #[case(FlagError::NoGroupTypeMappings, 500, "no_group_type_mappings")]
#[case(
FlagError::DependencyNotFound(DependencyType::Flag, 1),
500,
@@ -1234,14 +1232,9 @@ mod tests {
"cohort_filters_parsing_error"
)]
#[case(FlagError::PersonNotFound, 503, "person_not_found")]
- #[case(FlagError::PropertiesNotInCache, 503, "properties_not_in_cache")]
- #[case(
- FlagError::StaticCohortMatchesNotCached,
- 503,
- "static_cohort_not_cached"
- )]
#[case(FlagError::CacheMiss, 503, "cache_miss")]
#[case(FlagError::DataParsingError, 500, "data_parsing_error")]
+ #[case(FlagError::HashKeyOverrideError, 500, "hash_key_override_error")]
fn test_set_error_populates_fields(
#[case] error: FlagError,
#[case] expected_status: u16,