Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Prevent hardcoding of feature flags.

Type of Change

  • Other: CI Improvement

Testing

Testing via CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 13, 2026 6:42pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 13, 2026

Greptile Summary

This PR enhances the CI workflow to prevent hardcoded feature flags by adding two validation checks: (1) detecting hardcoded boolean literals like export const isHosted = true using perl multiline pattern matching, and (2) enforcing naming conventions requiring feature flags to use is or get prefixes. This addresses previous feedback about multiline declarations not being caught.

Key improvements:

  • Upgraded from single-line grep to perl multiline regex to catch declarations split across lines
  • Added naming convention validation to enforce consistent is* prefix for boolean flags
  • Clear error messages guide developers on proper implementation patterns

Issues found:

  • Pattern doesn't catch type annotations (e.g., export const isFoo: boolean = true)
  • Comments between assignment operator and value can bypass detection
  • Both checks depend on perl being available in the CI environment (likely but not guaranteed)

Confidence Score: 3/5

  • Safe to merge with known limitations - provides meaningful protection against common hardcoding mistakes
  • The implementation addresses the previous review's multiline concern and adds naming validation, which catches the most common hardcoding patterns. However, two edge cases (type annotations and inline comments) can bypass detection. These are unlikely scenarios in practice but represent real gaps in coverage. The CI improvement adds value despite imperfections.
  • .github/workflows/test-build.yml - review the regex patterns if comprehensive feature flag protection is critical

Important Files Changed

Filename Overview
.github/workflows/test-build.yml Adds feature flag validation with hardcoded boolean check and naming convention enforcement. Addresses previous multiline regex issue but has edge cases with type annotations.

Sequence Diagram

sequenceDiagram
    participant CI as GitHub Actions CI
    participant Checkout as Checkout Code
    participant Validation as Feature Flag Validation
    participant File as feature-flags.ts
    participant Perl as Perl Pattern Matcher
    participant Grep as Grep Pattern Matcher
    participant Lint as Lint Check

    CI->>Checkout: Start workflow
    Checkout->>CI: Code checked out
    CI->>Validation: Run validation step
    Validation->>File: Read feature-flags.ts
    
    Note over Validation,Perl: Check 1: Hardcoded Booleans
    Validation->>Perl: perl -0777 multiline regex
    Perl->>Perl: Search for "export const is* = true/false"
    Perl-->>Validation: Return matches (if any)
    
    alt Hardcoded booleans found
        Validation->>CI: ❌ Exit 1 - Hardcoded flags detected
    else No hardcoded booleans
        Note over Validation,Grep: Check 2: Naming Conventions
        Validation->>Grep: grep -E lowercase exports
        Grep->>Grep: Filter out "is" and "get" prefixes
        Grep-->>Validation: Return non-compliant names
        
        alt Bad naming found
            Validation->>CI: ❌ Exit 1 - Invalid naming
        else All checks pass
            Validation->>CI: ✅ Validation passed
            CI->>Lint: Continue to lint
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 13, 2026

Additional Comments (2)

apps/sim/lib/core/config/feature-flags.ts
This hardcoded true value violates the CI check you just added. The new CI workflow will fail on this exact line.

export const isHosted =
  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/core/config/feature-flags.ts
Line: 24:24

Comment:
This hardcoded `true` value violates the CI check you just added. The new CI workflow will fail on this exact line.

```suggestion
export const isHosted =
  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
```

How can I resolve this? If you propose a fix, please make it concise.

apps/sim/lib/core/config/feature-flags.ts
getEnv is still needed for isHosted

import { env, getEnv, isFalsy, isTruthy } from './env'
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/core/config/feature-flags.ts
Line: 4:4

Comment:
`getEnv` is still needed for `isHosted`

```suggestion
import { env, getEnv, isFalsy, isTruthy } from './env'
```

How can I resolve this? If you propose a fix, please make it concise.

@icecrasher321
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit 40a066f into staging Jan 13, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the improvement/ci-check-FF branch January 13, 2026 18:47
waleedlatif1 pushed a commit that referenced this pull request Jan 13, 2026
* improvement(FF): CI check to prevent hardcoding of FFs

* revert test change

* add FF lint checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants