Skip to content

Add failing tests for #451: default_language ignored in language detection#462

Draft
Serhan-Asad wants to merge 1 commit intopromptdriven:mainfrom
Serhan-Asad:fix/issue-451
Draft

Add failing tests for #451: default_language ignored in language detection#462
Serhan-Asad wants to merge 1 commit intopromptdriven:mainfrom
Serhan-Asad:fix/issue-451

Conversation

@Serhan-Asad
Copy link
Contributor

Summary

Adds failing tests that detect the bug reported in #451 where the default_language setting in .pddrc is ignored during language detection.

Test Files

  • Unit test: tests/test_construct_paths.py::test_default_language_fallback_from_pddrc
  • E2E test: tests/test_e2e_issue_451_default_language.py (5 comprehensive tests)

What This PR Contains

  • Failing unit test that reproduces the exact bug with isolated language detection logic
  • Failing E2E test suite that verifies the bug at integration level through the full CLI path
  • Tests are verified to fail on current code and will pass once the bug is fixed

Root Cause

Location: pdd/construct_paths.py:688 in _determine_language()

Issue: Key name mismatch where:

  1. Configuration correctly stores value as command_options["default_language"]
  2. Language detection checks command_options.get("language") (wrong key!)
  3. No fallback logic exists to check default_language before raising error at line 762

Impact: Users configure default_language: python in .pddrc, but pdd generate test.prompt (without language suffix) fails with "Could not determine language from input files or options."

The Fix

Add 4 lines before line 762 in pdd/construct_paths.py:

# 5 - Check default_language from .pddrc as fallback
default_lang = command_options.get("default_language")
if default_lang:
    return default_lang.lower()

# 6 - If no language determined, raise error
raise ValueError("Could not determine language from input files or options.")

This establishes the correct priority order:

  1. CLI --language flag (highest priority)
  2. Code file extension (.py → python)
  3. Prompt filename suffix (_python.prompt → python)
  4. default_language from .pddrc (NEW FALLBACK)
  5. Error if none found

Test Coverage

The test suite verifies:

  • ✅ Main bug: default_language from .pddrc is used as fallback
  • ✅ Priority: Filename suffix overrides config default
  • ✅ Priority: CLI flag overrides config default
  • ✅ Priority: File extension overrides config default
  • ✅ Regression: Error still raised when NO language source exists
  • ✅ Edge case: Case-insensitive handling

Next Steps

  1. Implement the fix at pdd/construct_paths.py:762
  2. Verify unit test passes: pytest tests/test_construct_paths.py::test_default_language_fallback_from_pddrc -v
  3. Verify E2E tests pass: pytest tests/test_e2e_issue_451_default_language.py -v
  4. Run full test suite: pytest tests/
  5. Mark PR as ready for review

Fixes #451


Generated by PDD agentic bug workflow (Steps 1-10)

…d in language detection

This commit adds comprehensive test coverage that reproduces the bug where
the default_language setting in .pddrc is ignored during language detection.

Tests added:
- Unit test: test_default_language_fallback_from_pddrc in test_construct_paths.py
- E2E test suite: test_e2e_issue_451_default_language.py with 5 comprehensive tests

Both test suites currently FAIL, correctly detecting the bug where:
- Configuration loads default_language correctly into command_options
- _determine_language() checks command_options.get("language") (wrong key)
- Function never checks command_options.get("default_language") as fallback
- Error is raised without using the configured default

The tests will PASS once the fix is applied (adding fallback check for
default_language before raising error at line 762 in construct_paths.py).

Related to promptdriven#451

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

Language detection ignores .pddrc default_language setting

1 participant