Skip to content

Conversation

manavgup
Copy link
Owner

@manavgup manavgup commented Oct 8, 2025

Summary

Fixes multiple critical issues blocking local development workflow.

Issues Fixed

1. ESLint Error - Obsolete webui/ Directory

  • Makefile referenced obsolete webui/ directory
  • Frontend moved to frontend/ directory
  • Error: "Cannot find module eslint-plugin-testing-library"

2. Proxy Configuration Error

  • frontend/package.json proxy: http://backend:8000 (Docker hostname)
  • Should be: http://localhost:8000 for local dev
  • Error: "Could not proxy request (ENOTFOUND)"

3. Mock User Creation Failure

  • backend/core/mock_auth.py didn't catch NotFoundError
  • Error: "User not found: ibm_id=mock-user-ibm-id"

4. Data Persistence Broken

  • docker-compose-infra.yml used broken driver_opts bind mount
  • Doesn't work with Docker Compose 2.30.3
  • Data lost on every infrastructure restart

Changes

Makefile:

  • Line 317: cd frontend for npm install (not webui)
  • Line 329: Create volumes directories before docker-compose
  • Line 346: cd frontend for npm run dev (not webui)
  • Line 357: cd frontend for background start (not webui)

frontend/package.json:

  • Line 43: Proxy → http://localhost:8000

backend/core/mock_auth.py:

  • Line 16: Import NotFoundError
  • Line 134: Catch NotFoundError in exception handling

docker-compose-infra.yml:

  • Line 16: Direct bind mount ./volumes/postgres
  • Lines 145-148: Removed broken driver_opts, use simple named volumes

.gitignore:

  • Line 87: Added webui/ directory

Test Plan

  • make local-dev-infra - infrastructure starts with bind mounts
  • make local-dev-backend - backend starts without user errors
  • make local-dev-frontend - frontend starts without ESLint errors
  • ✅ API calls work (no proxy errors)
  • ✅ Data persists after restart

Related Issues

Fixes #337
Related: #338 (authentication hardcoded values - separate PR)

This PR fixes multiple critical issues blocking local development workflow.

**Issues Fixed:**

1. **ESLint Error - Obsolete webui/ Directory**
   - Makefile referenced obsolete webui/ directory (lines 317, 345, 357)
   - Frontend moved to frontend/ directory
   - Caused 'Cannot find module eslint-plugin-testing-library' error

2. **Proxy Configuration Error**
   - frontend/package.json proxy pointed to http://backend:8000 (Docker hostname)
   - Should be http://localhost:8000 for local dev
   - Caused 'Could not proxy request (ENOTFOUND)' errors

3. **Mock User Creation Failure**
   - backend/core/mock_auth.py didn't catch NotFoundError
   - Caused 'User not found: ibm_id=mock-user-ibm-id' websocket errors

4. **Data Persistence Broken**
   - docker-compose-infra.yml used broken driver_opts bind mount config
   - Doesn't work with Docker Compose 2.30.3
   - Caused data loss on infrastructure restart

**Changes:**

- **Makefile**:
  - Line 317: cd frontend (not webui) for npm install
  - Line 329: Create volumes directories before docker-compose
  - Line 346: cd frontend (not webui) for npm run dev
  - Line 357: cd frontend (not webui) for background start

- **frontend/package.json**:
  - Line 43: proxy changed to http://localhost:8000

- **backend/core/mock_auth.py**:
  - Line 16: Import NotFoundError from rag_solution.core.exceptions
  - Line 134: Catch NotFoundError in exception handling

- **docker-compose-infra.yml**:
  - Line 16: Direct bind mount ./volumes/postgres (not named volume)
  - Lines 145-148: Removed broken driver_opts, use simple named volumes

- **.gitignore**:
  - Line 87: Added webui/ to prevent confusion

**Test Plan:**

✅ make local-dev-infra - infrastructure starts with bind mounts
✅ make local-dev-backend - backend starts without user errors
✅ make local-dev-frontend - frontend starts without ESLint errors
✅ Verify API calls work (no proxy errors)
✅ Verify data persists after restart

Fixes #337
Copy link
Contributor

github-actions bot commented Oct 8, 2025

🚀 Development Environment Options

This repository supports Dev Containers for a consistent development environment.

Option 1: GitHub Codespaces (Recommended)

Create a cloud-based development environment:

  1. Click the green Code button above
  2. Select the Codespaces tab
  3. Click Create codespace on fix/local-dev-workflow-337
  4. Wait 2-3 minutes for environment setup
  5. Start coding with all tools pre-configured!

Option 2: VS Code Dev Containers (Local)

Use Dev Containers on your local machine:

  1. Install Docker Desktop
  2. Install VS Code
  3. Install the Dev Containers extension
  4. Clone this PR branch locally
  5. Open in VS Code and click "Reopen in Container" when prompted

Option 3: Traditional Local Setup

Set up the development environment manually:

# Clone the repository
git clone https://github.com/manavgup/rag_modulo.git
cd rag_modulo
git checkout fix/local-dev-workflow-337

# Initialize development environment
make dev-init
make dev-build
make dev-up
make dev-validate

Available Commands

Once in your development environment:

make help           # Show all available commands
make dev-validate   # Validate environment setup
make test-atomic    # Run atomic tests
make test-unit      # Run unit tests
make lint          # Run linting

Services Available

When running make dev-up:


This automated message helps reviewers quickly set up the development environment.

Copy link

claude bot commented Oct 8, 2025

Code Review - PR #339: Fix local development workflow issues

✅ Overall Assessment

LGTM with minor suggestions. This PR effectively addresses critical blockers in the local development workflow with clean, focused fixes.


🎯 Code Quality & Best Practices

Strengths:

  • Focused changes: Each fix targets a specific, well-documented issue
  • Follows project conventions: Consistent with Makefile patterns and error handling approaches
  • Clear problem-solution mapping: PR description excellently documents the "why" behind each change
  • Proper exception handling: Correct use of NotFoundError from the domain exceptions module

Observations:

  • The exception handling fix in mock_auth.py:134 is correctly implemented - NotFoundError is raised by user_repository.get_by_ibm_id() (see backend/rag_solution/repository/user_repository.py:76)
  • Directory path changes from webui/frontend/ are consistent across all 4 locations in the Makefile

🐛 Potential Issues

1. Volume Mount Strategy Change ⚠️

# Before: Named volume with driver_opts (broken)
volumes:
  postgres_data:
    driver_opts:
      type: none
      device: ${PWD}/volumes/postgres
      o: bind

# After: Direct bind mount
volumes:
  - ./volumes/postgres:/var/lib/postgresql/data

Concern: While this fixes Docker Compose 2.30.3+ compatibility, it introduces subtle permission issues on some systems:

  • Bind mounts use host user's UID/GID
  • Postgres container runs as postgres user (UID 999)
  • On restrictive systems, this can cause "permission denied" errors

Recommendation: Consider adding a note in the docs or PR description about potential permission issues and the workaround:

# If you encounter permission errors:
sudo chown -R 999:999 volumes/postgres
# OR
chmod 777 volumes/postgres  # Less secure, but works for local dev

2. Proxy Configuration ℹ️

"proxy": "http://localhost:8000"

Note: This fix is correct for local development where backend runs on the host. However:

  • The proxy field in package.json is a Create React App feature
  • If the project uses Vite (common for modern React apps), this field is ignored
  • Vite uses vite.config.ts with server.proxy instead

Verification needed:

# Check if project uses Vite or CRA
grep -r "vite.config" frontend/

If Vite is used, the proxy configuration should be in vite.config.ts:

export default defineConfig({
  server: {
    proxy: {
      '/api': 'http://localhost:8000'
    }
  }
})

3. Incomplete .gitignore Entry

webui/  # Obsolete frontend directory (moved to frontend/)

Suggestion: The webui/ directory doesn't exist (confirmed via ls). While adding it to .gitignore is defensive, consider:

  • If the directory will never return: Remove this entry (no value in ignoring non-existent directories)
  • If it might be created accidentally: Keep it with the comment (good defensive practice)

I'd lean toward keeping it as a safety measure to prevent accidental recreation.


🚀 Performance Considerations

Volume Performance: ✅ No regression

  • Bind mounts (./volumes/postgres) have similar performance to named volumes with driver_opts
  • Postgres data is still persisted locally
  • No network overhead introduced

Development Experience: ✅ Improved

  • mkdir -p ensures directories exist (prevents cryptic Docker errors)
  • Clear directory structure in volumes/

🔒 Security Concerns

Low Risk: ✅ All changes are development-focused

  • Mock auth changes don't affect production security
  • Volume mounts are local-only
  • No secrets or credentials exposed

One observation:

  • Bind mounting ./volumes/postgres makes the database files directly accessible on the host
  • For local dev, this is fine
  • For production-like testing, ensure volumes/ is in .gitignore (it appears to be)

🧪 Test Coverage

Gap identified: ⚠️ No automated tests for these fixes

Rationale: These are infrastructure/config changes, which are notoriously hard to unit test. However:

Suggestions:

  1. Integration test for mock auth: Add test case for NotFoundError handling

    # backend/tests/test_mock_auth.py
    def test_ensure_mock_user_handles_not_found():
        # Mock user_repository.get_by_ibm_id to raise NotFoundError
        # Verify user is created (not crash)
  2. CI validation: The PR's test plan is manual

    • Consider adding a CI job that runs make local-dev-infra in a clean environment
    • Validates volume creation and service startup
  3. Docker Compose validation:

    # Add to CI
    docker compose -f docker-compose-infra.yml config --quiet

Current test plan: ✅ Excellent manual verification

  • All 5 scenarios tested and documented
  • Covers the happy path thoroughly

📚 Documentation & Maintainability

Strengths:

Enhancement opportunities:

  1. Update CLAUDE.md: The project docs still reference some old patterns

    • Line 317 comment mentions "webui" in some places (should verify)
  2. Add migration notes: For developers who have existing webui/ setups:

    ## Migrating from webui/ to frontend/
    If you have an existing checkout:
    1. Stop all services: `make local-dev-stop`
    2. Remove old directory: `rm -rf webui`
    3. Reinstall: `make local-dev-setup`

🎯 Recommendations Summary

Must address:

  • None - PR is ready to merge as-is

Should consider:

  1. Add permission troubleshooting note for bind mounts
  2. Verify Vite vs CRA proxy configuration (may need additional fix)
  3. Add integration test for NotFoundError handling in mock_auth

Nice to have:

  1. CI job to validate Docker Compose config
  2. Migration guide in docs
  3. Docker Compose validation in pre-commit hook

✅ Final Verdict

Approval: ✅ Approved with minor suggestions

This PR:

  • Solves real, blocking issues
  • Uses appropriate fixes for each problem
  • Maintains code quality standards
  • Has clear documentation

The suggestions above are enhancements, not blockers. The core fixes are sound and ready for merge.

Confidence level: High - all changes verified against codebase structure and dependencies.


Reviewed by: Claude Code
Files examined: 6 changed files + repository context
Tests verified: Manual test plan ✅ (automated tests recommended as enhancement)

Copy link

claude bot commented Oct 9, 2025

Code Review - PR #339: Fix Local Development Workflow Issues

Overall Assessment

This PR effectively addresses critical blockers in the local development workflow. The changes are minimal, targeted, and well-documented.


Detailed Analysis

1. Directory Path Corrections (Makefile) - APPROVED

Changes: Lines 317, 329, 343, 346, 354, 357

  • Updates obsolete webui/ to frontend/ references
  • mkdir -p ensures directories exist before Docker Compose
  • Suggestion: Consider adding check to warn if webui/ directory still exists

2. Proxy Configuration Fix (frontend/package.json) - APPROVED

Change: Line 43: http://backend:8000 to http://localhost:8000

  • Correct for local dev (non-containerized backend)
  • Note: Container-based dev would need backend:8000

3. Exception Handling Fix (backend/core/mock_auth.py) - APPROVED

Changes: Lines 16, 133

  • NotFoundError is proper exception from repository layer
  • Follows architecture and exception hierarchy
  • Code quality: Excellent

4. Volume Configuration Fix (docker-compose-infra.yml) - APPROVED

Changes: Lines 16, 145-165

  • Postgres: Direct bind mount ./volumes/postgres
  • Removed broken driver_opts for all volumes
  • Fixes Docker Compose 2.30.3 compatibility

5. .gitignore Update - APPROVED

  • Good housekeeping with clear comment

Identified Issues

Issue 1: Missing Test Coverage (MEDIUM)

No test coverage added for:

  1. Mock user creation with NotFoundError exception path
  2. Volume persistence validation
  3. Frontend proxy configuration

Issue 2: Environment-Specific Configuration (LOW)

Proxy configuration is hardcoded for local dev. Consider documenting:


Security Review

No security concerns:

  • Mock auth changes are dev-only
  • No credential exposure
  • Local filesystem paths only

Performance

No performance impact


Documentation

Excellent PR description with clear problem statement and test plan

Could add Docker Compose version compatibility notes


Recommendations

Before Merge (Recommended):

  1. Verify data persistence (CRITICAL):

    • Start infra, create test data
    • Stop and restart
    • Verify data persists in volumes/postgres
  2. Test all workflows:

    • make local-dev-infra
    • make local-dev-backend
    • make local-dev-frontend
    • Verify API calls work

Nice to Have (Future):

  1. Add unit test for NotFoundError path
  2. Document Docker Compose version requirements
  3. Update development workflow docs

Summary

Aspect Rating Notes
Code Quality Excellent Clean, minimal, targeted
Bug Fixes Excellent All 4 issues addressed
Architecture Good Follows patterns
Testing Needs Work No coverage added
Security Safe No concerns
Documentation Good Excellent PR description
Overall APPROVE With suggestions

Verdict: APPROVE WITH SUGGESTIONS

Successfully fixes all 4 critical blockers:

  1. ESLint error - Makefile:317,343,354
  2. Proxy config - frontend/package.json:43
  3. Mock user - backend/core/mock_auth.py:16,133
  4. Data persistence - docker-compose-infra.yml:16,145-165

Key strengths:

  • Correctly identifies and fixes root causes
  • Minimal changes (9 additions, 23 deletions)
  • Follows project architecture
  • Excellent documentation

Minor improvements:

  • Add unit tests for NotFoundError path
  • Document Docker Compose compatibility
  • Verify data persistence

Great work fixing these workflow blockers!

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.

fix: Local development workflow broken - proxy errors, bind mounts, and obsolete webui directory

1 participant