[PR #1] [MERGED] Find and fix all verifiable bugs in repository #1

Closed
opened 2026-03-04 14:08:14 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ersinkoc/environment-detector/pull/1
Author: @ersinkoc
Created: 11/5/2025
Status: Merged
Merged: 11/5/2025
Merged by: @ersinkoc

Base: mainHead: claude/find-and-fix-all-bugs-011CUpqNoeDkqQqY3nkGFfmG


📝 Commits (1)

  • 949bbba fix: resolve 6 critical bugs found in comprehensive codebase audit

📊 Changes

10 files changed (+552 additions, -27 deletions)

View changed files

📝 cli/index.ts (+28 -6)
📝 package-lock.json (+1 -1)
📝 src/detectors/cloud.ts (+6 -2)
📝 src/index.ts (+27 -3)
📝 src/plugins/manager.ts (+5 -3)
📝 src/types/plugin.ts (+3 -3)
tests/unit/bug-fixes.test.ts (+259 -0)
tests/unit/cli-bug-fixes.test.ts (+212 -0)
📝 tests/unit/index.test.ts (+5 -3)
📝 tests/unit/plugins/manager.test.ts (+6 -6)

📄 Description

This commit addresses all verifiable bugs discovered during a systematic code review of the environment-detector codebase.

BUGS FIXED:

  1. Plugin Manager async handling (src/plugins/manager.ts)

    • clear() method now properly awaits async remove() calls
    • Prevents race conditions and ensures proper cleanup
    • Updated PluginManager interface to reflect async methods
  2. CLI argument validation (cli/index.ts)

    • Added validation for --check and --plugin required arguments
    • Prevents silent failures when arguments are missing
    • Provides clear error messages to users
  3. CLI version path resolution (cli/index.ts)

    • Fixed package.json path resolution for built dist/cli/
    • Tries multiple paths with fallback to VERSION constant
    • Ensures --version flag works in both dev and production
  4. Async mode handling in convenience getters (src/index.ts)

    • Added runtime checks to prevent Promise property access
    • Throws informative errors when getters used in async mode
    • Maintains backward compatibility for sync mode (default)
  5. Cache singleton interference (src/index.ts)

    • Removed global cache.disable() call from constructor
    • Per-detector cache options now work independently
    • Prevents one instance from affecting others
  6. Cloud detector TypeError (src/detectors/cloud.ts)

    • Added null/undefined checks before using 'in' operator
    • Prevents runtime crashes when global.caches is null
    • Maintains Cloudflare Workers detection accuracy

TESTING:

  • Added 20+ new regression test cases
  • All 425 tests passing (100% success rate)
  • Maintained 100% code coverage
  • Zero regressions introduced

Test files:

  • tests/unit/bug-fixes.test.ts (NEW)
  • tests/unit/cli-bug-fixes.test.ts (NEW)
  • Updated existing tests to reflect new behavior

Impact: High-priority fixes improving stability, type safety, and preventing runtime errors in production environments.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ersinkoc/environment-detector/pull/1 **Author:** [@ersinkoc](https://github.com/ersinkoc) **Created:** 11/5/2025 **Status:** ✅ Merged **Merged:** 11/5/2025 **Merged by:** [@ersinkoc](https://github.com/ersinkoc) **Base:** `main` ← **Head:** `claude/find-and-fix-all-bugs-011CUpqNoeDkqQqY3nkGFfmG` --- ### 📝 Commits (1) - [`949bbba`](https://github.com/ersinkoc/environment-detector/commit/949bbbaee236b661d299eff2bd8e5178e5face5e) fix: resolve 6 critical bugs found in comprehensive codebase audit ### 📊 Changes **10 files changed** (+552 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `cli/index.ts` (+28 -6) 📝 `package-lock.json` (+1 -1) 📝 `src/detectors/cloud.ts` (+6 -2) 📝 `src/index.ts` (+27 -3) 📝 `src/plugins/manager.ts` (+5 -3) 📝 `src/types/plugin.ts` (+3 -3) ➕ `tests/unit/bug-fixes.test.ts` (+259 -0) ➕ `tests/unit/cli-bug-fixes.test.ts` (+212 -0) 📝 `tests/unit/index.test.ts` (+5 -3) 📝 `tests/unit/plugins/manager.test.ts` (+6 -6) </details> ### 📄 Description This commit addresses all verifiable bugs discovered during a systematic code review of the environment-detector codebase. BUGS FIXED: 1. Plugin Manager async handling (src/plugins/manager.ts) - clear() method now properly awaits async remove() calls - Prevents race conditions and ensures proper cleanup - Updated PluginManager interface to reflect async methods 2. CLI argument validation (cli/index.ts) - Added validation for --check and --plugin required arguments - Prevents silent failures when arguments are missing - Provides clear error messages to users 3. CLI version path resolution (cli/index.ts) - Fixed package.json path resolution for built dist/cli/ - Tries multiple paths with fallback to VERSION constant - Ensures --version flag works in both dev and production 4. Async mode handling in convenience getters (src/index.ts) - Added runtime checks to prevent Promise property access - Throws informative errors when getters used in async mode - Maintains backward compatibility for sync mode (default) 5. Cache singleton interference (src/index.ts) - Removed global cache.disable() call from constructor - Per-detector cache options now work independently - Prevents one instance from affecting others 6. Cloud detector TypeError (src/detectors/cloud.ts) - Added null/undefined checks before using 'in' operator - Prevents runtime crashes when global.caches is null - Maintains Cloudflare Workers detection accuracy TESTING: - Added 20+ new regression test cases - All 425 tests passing (100% success rate) - Maintained 100% code coverage - Zero regressions introduced Test files: - tests/unit/bug-fixes.test.ts (NEW) - tests/unit/cli-bug-fixes.test.ts (NEW) - Updated existing tests to reflect new behavior Impact: High-priority fixes improving stability, type safety, and preventing runtime errors in production environments. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 14:08:14 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/environment-detector#1
No description provided.