Flag Not Detected
Troubleshooting when FlagShark doesn't detect your feature flags.
If FlagShark isn't detecting flags you expect it to find, this guide will help you diagnose and resolve the issue.
Quick Checklist
Before diving into detailed troubleshooting, verify these basics:
- The repository is tracked (not just added) in FlagShark
- The flag is in a supported language (Supported Languages)
- For PRs: The flag is in the PR diff (not just in the file)
- For direct commits: The commit was pushed to the default branch (main/master)
- The file isn't excluded by configuration
- You're using a supported SDK or have custom configuration
- FlagShark has access to the repository
Common Causes
Understanding Detection Triggers
FlagShark detects flags in two scenarios:
| Trigger | What's Detected | Where It Appears |
|---|---|---|
| PR opened/updated | Flags in the diff | PR comment (preview) |
| Push to default branch | Flags added/removed | Dashboard inventory |
1. Repository Not Tracked
Adding a repository to your FlagShark installation doesn't automatically enable monitoring. You must track the repository:
2. Flag Not in the Diff (PRs)
For PR comments: FlagShark only shows flags in changed lines. If a flag exists in a file but the line wasn't modified, it won't appear in that PR's comment.
For dashboard inventory: Flags are tracked when they're added to or removed from your default branch, regardless of whether they appeared in a PR comment.
Example:
function MyComponent() {
const enabled = useFlags().myFlag; // Not detected - line unchanged
+ const newFeature = true; // Only this line is in the diff
return <div>...</div>;
}
Solutions:
- For PR comments: This is expected behavior for PR analysis
- For dashboard: Run a full repository scan from Settings → Repositories to discover all existing flags
3. Unsupported Language
FlagShark supports specific file extensions. If your file uses an unusual extension, it may not be analyzed.
Check the extension:
| Supported | Not Supported |
|---|---|
.ts, .tsx | .mts, .cts (partial) |
.js, .jsx | .es6 |
.py | .pyw |
.go | - |
.rs | - |
.cs | - |
See Supported Languages for the complete list.
4. Unsupported SDK Pattern
FlagShark detects specific SDK method calls. If you're using a custom wrapper or uncommon SDK, you may need custom configuration.
Works out of the box:
// LaunchDarkly
ldClient.variation('my-flag', user, false);
const { myFlag } = useFlags();
// Unleash
unleash.isEnabled('my-flag');
Needs configuration:
// Custom wrapper
featureFlags.check('my-flag'); // Won't work without config
// Internal SDK
companyFlags.isEnabled('my-flag'); // Won't work without config
Solution: Add custom provider configuration in .flagshark.yaml:
providers:
- name: "Custom Flags"
package_path: "company/feature-flags"
methods:
- name: "check"
flag_key_index: 0
- name: "isEnabled"
flag_key_index: 0
5. Dynamic Flag Keys
FlagShark can only detect flags with static string keys. Dynamic keys cannot be resolved at parse time.
Detected:
// Static string - detected
const enabled = ldClient.variation('enable-feature', user, false);
// Template literal with only static parts - detected
const enabled = ldClient.variation(`enable-feature`, user, false);
Not detected:
// Variable - not detected
const flagName = 'enable-feature';
const enabled = ldClient.variation(flagName, user, false);
// Function result - not detected
const enabled = ldClient.variation(getFlagName(), user, false);
// Dynamic template - not detected
const enabled = ldClient.variation(`enable-${feature}`, user, false);
Solution: Use static strings for flag keys. If you need dynamic keys, the flags can't be automatically detected.
6. File Excluded by Configuration
Check if the file is excluded in your .flagshark.yaml:
exclude:
- "**/*.test.ts"
- "vendor/**"
- "generated/**"
Solution: Remove the file from exclusions or adjust the pattern.
7. Comments or Strings
FlagShark ignores flags in comments and standalone strings:
// This is commented out: ldClient.variation('flag', user, false);
// Not detected ^
const description = "We use ldClient.variation('flag') for feature flags";
// String, not code - not detected ^
/*
ldClient.variation('old-flag', user, false);
Not detected - inside comment block ^
*/
8. Repository Not Connected
FlagShark must have access to the repository:
9. Webhook Not Delivered
GitHub may not have sent the webhook to FlagShark:
Common webhook issues:
| Status | Meaning | Action |
|---|---|---|
| 200 | Success | Webhook delivered, check FlagShark |
| 401 | Auth failed | Reinstall the GitHub App |
| 404 | Not found | Contact FlagShark support |
| No delivery | Not sent | Check webhook configuration |
Debugging Steps
Step 1: Verify the Flag in Code
Make sure the flag is actually present in the code as you expect:
// Verify this exact pattern exists in your PR diff
const enabled = ldClient.variation('my-flag-key', context, false);
Step 2: Check the File Extension
Confirm the file has a supported extension:
# Good
src/features/checkout.ts
src/features/checkout.tsx
src/features/checkout.py
# May not work
src/features/checkout.mts
src/features/checkout.es6
Step 3: Verify the Diff
On GitHub, check that the flag line is actually in the diff:
+ (addition) markerScreenshot needed: PR diff view showing added lines with + markers in greenGitHub Pull Request → Files changed diff
Step 4: Check Configuration
If you have a .flagshark.yaml, verify it's valid:
# Check for YAML syntax errors
# The file should be in repository root
cat .flagshark.yaml
Look for:
- Correct indentation (YAML is space-sensitive)
- Valid method configurations
- No typos in provider names
Step 5: Test with a Known Pattern
Create a test PR with a definitely-supported pattern:
// test-flag.ts
import LaunchDarkly from 'launchdarkly-node-server-sdk';
const client = LaunchDarkly.init('test-key');
const enabled = await client.variation('test-flag-detection', context, false);
If this is detected, the issue is with your specific SDK or pattern.
Step 6: Check Processing Status
In FlagShark dashboard:
Specific SDK Issues
LaunchDarkly React
The useFlags() hook returns an object. FlagShark detects both patterns:
// Pattern 1: Destructuring - detected
const { myFlag, anotherFlag } = useFlags();
// Pattern 2: Property access - detected
const flags = useFlags();
if (flags.myFlag) { }
// Pattern 3: Nested access - may not be detected
const flags = useFlags();
const value = flags['dynamic-' + key]; // Dynamic - not detected
LaunchDarkly Node
Make sure you're using the client methods:
// Detected
client.variation('flag', context, false);
client.boolVariation('flag', context, false);
// Not detected - internal methods
client.waitForInitialization(); // Not a flag
Unleash
Both isEnabled and getVariant are detected:
// Detected
const enabled = unleash.isEnabled('my-flag');
const variant = unleash.getVariant('my-flag');
// Not detected - configuration methods
unleash.on('ready', () => { }); // Not a flag
Request Help
If you've tried everything and flags still aren't detected:
Contact support: Email support@flagshark.io with the above info
Include code sample: A minimal example showing the pattern that isn't detected