Skip to content

Remove development debug code from production builds (#10521) #10522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

praneeth622
Copy link

@praneeth622 praneeth622 commented Jul 4, 2025

Fix: Remove development debug code from production builds

Description

This PR removes development-only debugging code that was incorrectly executing in production builds, addressing security concerns and console pollution. The changes ensure that debug functionality is only available during development while maintaining clean, secure production builds.

Key Changes:

  • Wrapped Debug component's window.props assignment in development-only condition
  • Removed debug console logs from ExamplesSelect component in production
  • Added environment checks to spec parsing error logging
  • Enhanced error handling with proper error state management

Motivation and Context

Fixes #10521

Problem: Development debugging code was running in production builds, causing:

  1. Security Risk: Internal application props exposed globally via window.props
  2. Console Pollution: Debug logs appearing in production console output
  3. Information Disclosure: Detailed error messages and stack traces exposed to end users
  4. Unprofessional Appearance: Debug output visible to production users

Root Cause: Missing environment checks around debug code, allowing development-only functionality to execute in production builds.

Solution: Implement proper process.env.NODE_ENV === "development" guards around all debug code to ensure it only runs during development.

How Has This Been Tested?

Development Environment Testing:

  • ✅ Verified window.props is accessible for debugging
  • ✅ Confirmed debug console logs appear correctly
  • ✅ Tested error parsing with detailed console output
  • ✅ Validated all existing debug functionality preserved

Production Environment Testing:

  • ✅ Built production bundle: npm run build
  • ✅ Served production build locally: npm run serve
  • ✅ Verified window.props is undefined in production
  • ✅ Confirmed clean console output with no debug logs
  • ✅ Tested error handling shows user-friendly messages only
  • ✅ Validated no internal state exposure

Cross-Browser Testing:

  • ✅ Chrome DevTools: No debug output in production
  • ✅ Firefox Console: Clean production console
  • ✅ Safari Web Inspector: No exposed internal state

Functional Testing:

  • ✅ All Swagger-UI features work correctly
  • ✅ Deep linking functionality preserved
  • ✅ Error handling still functions properly
  • ✅ Examples selection works without debug logs
  • ✅ Spec parsing errors handled gracefully

Security Testing:

  • ✅ No internal configuration exposed via global variables
  • ✅ No sensitive information in production console
  • ✅ Stack traces and internal paths not exposed

Testing Notes

  • ✅ Linting: Passed
  • ✅ Unit Tests: Passed (790 tests)
  • ⚠️ E2E Tests: Skipped due to missing system dependencies in development environment
  • Note: E2E tests will run in CI/CD environment with proper dependencies

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing

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.

Remove Development Debug Code from Production Builds
1 participant