Skip to content

chore(flags): remove dead FlagError variants#61000

Merged
haacked merged 2 commits into
masterfrom
fix/flag-error-remove-dead-variants
Jun 1, 2026
Merged

chore(flags): remove dead FlagError variants#61000
haacked merged 2 commits into
masterfrom
fix/flag-error-remove-dead-variants

Conversation

@haacked
Copy link
Copy Markdown
Contributor

@haacked haacked commented Jun 1, 2026

Problem

rust/feature-flags/src/api/errors.rs has accumulated FlagError variants that are never constructed anywhere in the codebase. They exist only in the enum definition, the error_metadata() / is_5xx() / IntoResponse arms, and test matrices. They add boilerplate flagged in #30174 without carrying any runtime meaning.

Part of #30174.

Note

This re-opens @ricardothe3rd's contribution from #55115 on an internal branch. Fork PRs can't read the Depot build token, so the build-images jobs fail with permission_denied before any code is validated. Running from an internal branch lets the full CI suite execute. The change is entirely @ricardothe3rd's work and their commits are preserved unmodified.

Changes

Removes 5 variants that a full-workspace grep and LSP check confirmed have zero construction sites outside errors.rs and its test modules:

  • DeserializeFiltersError
  • NoGroupTypeMappings
  • GroupTypeMappingFetchFailed
  • PropertiesNotInCache
  • StaticCohortMatchesNotCached

Also removes each variant's arm in error_metadata(), is_5xx(), and IntoResponse, the #[case] entries in the parameterized canonical_log.rs test, and the test vectors in errors.rs.

Net 77 deletions, 1 insertion across two files. There is no behavior change because the deleted code paths were unreachable in production.

Scoping note

This is preparatory cleanup for #30174. It does not yet introduce the InternalError(anyhow::Error) / Unavailable(anyhow::Error) buckets. That collapse is left to a follow-up so this PR stays a clean, low-risk, independently mergeable first step.

How did you test this code?

Verification from the original contribution, covering the cargo gates rather than a running service:

  • cargo check -p feature-flags, clean compile
  • cargo test -p feature-flags --lib api::errors, 14/14 pass
  • cargo test -p feature-flags --lib handler::canonical_log, 78/78 pass
  • cargo clippy -p feature-flags --all-targets, no new warnings
  • cargo fmt -p feature-flags --check, clean
  • Workspace-wide grep for each deleted variant name and its error_code() string, zero references outside the two edited files

Integration tests are left to CI, which has the pre-configured Django and ClickHouse environment.

Automatic notifications

  • Publish to changelog? no
  • Alert Sales and Marketing teams? no

Docs update

No docs changes needed.

Co-authored-by: Ricardo rarganaiii@gmail.com

Fixes: #55115

Copilot AI review requested due to automatic review settings June 1, 2026 18:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Hey @haacked! 👋

It looks like your git author email on this PR isn't your @posthog.com address (haacked@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Reviews (1): Last reviewed commit: "Merge branch 'master' into fix/flag-erro..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR cleans up the feature-flags Rust service error surface by removing FlagError enum variants that were no longer constructible anywhere in the repository, along with their now-unreachable handling and associated test matrix entries. This reduces boilerplate in preparation for the broader error-handling refactor described in #30174.

Changes:

  • Removed five dead FlagError variants and their match arms in error_metadata() / IntoResponse, plus related test vectors.
  • Updated canonical logging tests and error test matrices to reflect the reduced variant set (and to include HashKeyOverrideError in the canonical log test matrix).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rust/feature-flags/src/handler/canonical_log.rs Updates the parameterized canonical log test cases to remove deleted errors and include HashKeyOverrideError.
rust/feature-flags/src/api/errors.rs Removes dead FlagError variants and their response/metadata handling; updates test vectors accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@haacked haacked removed their assignment Jun 1, 2026
@haacked haacked added feature/feature-flags Feature Tag: Feature flags team/feature-flags labels Jun 1, 2026
Copy link
Copy Markdown
Contributor

@gustavohstrassburger gustavohstrassburger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trust stamp

@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Jun 1, 2026
Five variants are never constructed anywhere in the codebase:
  - DeserializeFiltersError
  - NoGroupTypeMappings
  - GroupTypeMappingFetchFailed
  - PropertiesNotInCache
  - StaticCohortMatchesNotCached

Removing them along with their arms in error_metadata, is_5xx,
IntoResponse, and parameterized test matrices.

Preparatory cleanup for #30174 before the InternalError/Unavailable
bucket collapse in a follow-up PR.
HashKeyOverrideError is a live 5xx variant but was missing from the
test_error_codes_are_non_empty, test_error_codes_are_unique,
test_error_code_consistency_with_is_5xx vecs, and the canonical_log.rs
parameterized case matrix. Adding it closes a pre-existing coverage gap
while the vectors are already open from the dead-variant removal above.

Per @haacked's review on #55115.
@haacked haacked force-pushed the fix/flag-error-remove-dead-variants branch from 33f75c5 to 142ce96 Compare June 1, 2026 19:00
@haacked haacked merged commit 5a44341 into master Jun 1, 2026
184 of 205 checks passed
@haacked haacked deleted the fix/flag-error-remove-dead-variants branch June 1, 2026 21:04
@github-project-automation github-project-automation Bot moved this from Approved to Done in Feature Flags Jun 1, 2026
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented Jun 1, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-01 21:42 UTC Run
prod-us ✅ Deployed 2026-06-02 10:18 UTC Run
prod-eu ✅ Deployed 2026-06-02 10:20 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants