diff --git a/.github/workflows/debug-powershell-quoting.yml b/.github/workflows/debug-powershell-quoting.yml new file mode 100644 index 0000000..34f67c9 --- /dev/null +++ b/.github/workflows/debug-powershell-quoting.yml @@ -0,0 +1,100 @@ +name: Debug PowerShell Quoting + +on: + workflow_dispatch: + pull_request: + +jobs: + debug-quoting: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e . + shell: pwsh + + - name: Test CLI accessibility + shell: pwsh + run: | + Write-Host "Testing basic CLI functionality..." + isic --help + + - name: Test simple metadata query (no spaces) + shell: pwsh + run: | + Write-Host "Testing simple query without spaces..." + isic metadata download -s "age_approx:50" --limit 1 + + - name: Debug: Show what PowerShell passes for different quotes + shell: pwsh + run: | + Write-Host "=== PowerShell Quoting Debug ===" + + # Test 1: Single quotes around the whole thing + $query1 = 'diagnosis_3:"Squamous cell carcinoma in situ"' + Write-Host "Query 1 (single quotes): '$query1'" + Write-Host "Length: $($query1.Length)" + Write-Host "Characters: $($query1.ToCharArray() -join ', ')" + + # Test 2: Double quotes with escaped inner quotes + $query2 = "diagnosis_3:`"Squamous cell carcinoma in situ`"" + Write-Host "Query 2 (backtick escape): `"$query2`"" + Write-Host "Length: $($query2.Length)" + Write-Host "Characters: $($query2.ToCharArray() -join ', ')" + + # Test 3: Double quotes inside single quotes + $query3 = 'diagnosis_3:""Squamous cell carcinoma in situ""' + Write-Host "Query 3 (doubled quotes): '$query3'" + Write-Host "Length: $($query3.Length)" + Write-Host "Characters: $($query3.ToCharArray() -join ', ')" + + - name: Test each quoting style with verbose output + shell: pwsh + run: | + Write-Host "=== Testing actual commands ===" + + Write-Host "`n1. Testing single quotes (Unix style):" + try { + isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 2>&1 | Tee-Object -Variable output1 + Write-Host "EXIT CODE: $LASTEXITCODE" + } catch { + Write-Host "EXCEPTION: $($_.Exception.Message)" + } + + Write-Host "`n2. Testing backtick escaping:" + try { + isic metadata download -s "diagnosis_3:`"Squamous cell carcinoma in situ`"" --limit 1 2>&1 | Tee-Object -Variable output2 + Write-Host "EXIT CODE: $LASTEXITCODE" + } catch { + Write-Host "EXCEPTION: $($_.Exception.Message)" + } + + Write-Host "`n3. Testing doubled quotes:" + try { + isic metadata download -s 'diagnosis_3:""Squamous cell carcinoma in situ""' --limit 1 2>&1 | Tee-Object -Variable output3 + Write-Host "EXIT CODE: $LASTEXITCODE" + } catch { + Write-Host "EXCEPTION: $($_.Exception.Message)" + } + + - name: Test with a known good diagnosis value + shell: pwsh + run: | + Write-Host "=== Testing with a simpler diagnosis value ===" + + # Try with a value that might not have special characters + Write-Host "Testing with 'melanoma':" + try { + isic metadata download -s 'diagnosis_3:"melanoma"' --limit 1 2>&1 + Write-Host "EXIT CODE: $LASTEXITCODE" + } catch { + Write-Host "EXCEPTION: $($_.Exception.Message)" + } \ No newline at end of file diff --git a/.github/workflows/powershell-quoting-test.yml b/.github/workflows/powershell-quoting-test.yml new file mode 100644 index 0000000..bdf7ae8 --- /dev/null +++ b/.github/workflows/powershell-quoting-test.yml @@ -0,0 +1,132 @@ +name: PowerShell Quoting Test + +on: + pull_request: + push: + branches: + - master + workflow_dispatch: + +jobs: + test-powershell-quoting: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e . + shell: pwsh + + - name: Test Unix-style quoting (should fail in PowerShell) + id: unix-style + shell: pwsh + continue-on-error: true + run: | + Write-Host "Testing Unix-style quoting: 'diagnosis_3:`"Squamous cell carcinoma in situ`"'" + $query = 'diagnosis_3:"Squamous cell carcinoma in situ"' + Write-Host "PowerShell will pass: $query" + isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 + + - name: Test incorrect PowerShell quoting (should also fail) + id: incorrect-powershell + shell: pwsh + continue-on-error: true + run: | + # This is what users might try but still fails + isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1 + + - name: Test correct PowerShell quoting with doubled quotes + id: correct-powershell-doubled + shell: pwsh + continue-on-error: true + run: | + # This should work - doubled quotes inside single quotes + isic metadata download -s 'diagnosis_3:""Squamous cell carcinoma in situ""' --limit 1 + + - name: Test correct PowerShell quoting with backticks + id: correct-powershell-backticks + shell: pwsh + continue-on-error: true + run: | + # This should work - backtick escaping + isic metadata download -s "diagnosis_3:`"Squamous cell carcinoma in situ`"" --limit 1 + + - name: Test simple query without spaces (should always work) + id: simple-query + shell: pwsh + run: | + # This should always work regardless of shell + isic metadata download -s 'age_approx:50' --limit 1 + + - name: Analyze test results + shell: pwsh + run: | + Write-Host "=== Test Results Analysis ===" + Write-Host "Unix-style quoting outcome: ${{ steps.unix-style.outcome }}" + Write-Host "Incorrect PowerShell quoting outcome: ${{ steps.incorrect-powershell.outcome }}" + Write-Host "Correct PowerShell doubled quotes outcome: ${{ steps.correct-powershell-doubled.outcome }}" + Write-Host "Correct PowerShell backticks outcome: ${{ steps.correct-powershell-backticks.outcome }}" + Write-Host "Simple query outcome: ${{ steps.simple-query.outcome }}" + + Write-Host "" + Write-Host "=== Analysis ===" + + # Count successes and failures + $successes = @("${{ steps.unix-style.outcome }}", "${{ steps.incorrect-powershell.outcome }}", "${{ steps.correct-powershell-doubled.outcome }}", "${{ steps.correct-powershell-backticks.outcome }}", "${{ steps.simple-query.outcome }}") | Where-Object { $_ -eq "success" } + $failures = @("${{ steps.unix-style.outcome }}", "${{ steps.incorrect-powershell.outcome }}", "${{ steps.correct-powershell-doubled.outcome }}", "${{ steps.correct-powershell-backticks.outcome }}", "${{ steps.simple-query.outcome }}") | Where-Object { $_ -eq "failure" } + + Write-Host "Total successes: $($successes.Count)" + Write-Host "Total failures: $($failures.Count)" + + if ($successes.Count -eq 5) { + Write-Host "🔍 All commands succeeded - this suggests either:" + Write-Host " 1. PowerShell is handling all quoting styles correctly, OR" + Write-Host " 2. The search validation is not strict enough to catch quoting issues" + Write-Host "✅ This is actually good news - the quoting issue may not exist or be as severe as expected" + } elseif ($failures.Count -eq 5) { + Write-Host "❌ All commands failed - this suggests:" + Write-Host " 1. Network/authentication issues, OR" + Write-Host " 2. Invalid diagnosis value, OR" + Write-Host " 3. CLI installation problems" + } else { + Write-Host "📊 Mixed results - this is the expected behavior if there's a real quoting issue" + Write-Host " - Some quoting styles work, others don't" + } + + Write-Host "" + Write-Host "This test run provides valuable data about PowerShell quoting behavior." + Write-Host "All outcomes are informative and help us understand the real issue." + + test-cmd-quoting: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -e . + shell: cmd + + - name: Test quoting in Command Prompt + shell: cmd + run: | + REM Test basic quoting in cmd.exe + isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1 + + - name: Test simple query in Command Prompt + shell: cmd + run: | + isic metadata download -s "age_approx:50" --limit 1 \ No newline at end of file diff --git a/test-diagnosis-values.sh b/test-diagnosis-values.sh new file mode 100755 index 0000000..e38d1fb --- /dev/null +++ b/test-diagnosis-values.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Test script to verify valid diagnosis values + +echo "Testing various diagnosis values to find valid ones..." +echo "============================================================" + +# Test simple values first +echo "Testing simple age query:" +isic metadata download -s 'age_approx:50' --limit 1 + +echo +echo "Testing diagnosis_3 with melanoma:" +isic metadata download -s 'diagnosis_3:melanoma' --limit 1 + +echo +echo "Testing diagnosis_3 with quotes around melanoma:" +isic metadata download -s 'diagnosis_3:"melanoma"' --limit 1 + +echo +echo "Testing if 'Squamous cell carcinoma in situ' is valid:" +isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 + +echo +echo "Testing a different approach with diagnosis_2:" +isic metadata download -s 'diagnosis_2:"Malignant melanocytic proliferations (Melanoma)"' --limit 1 + +echo +echo "Getting help to see example queries:" +isic metadata download --help | grep -A 10 -B 10 diagnosis \ No newline at end of file diff --git a/test-powershell-quoting.ps1 b/test-powershell-quoting.ps1 new file mode 100644 index 0000000..14e14d0 --- /dev/null +++ b/test-powershell-quoting.ps1 @@ -0,0 +1,56 @@ +# PowerShell script to test quoting behavior with isic-cli +# Run this in PowerShell to see how different quoting styles behave + +Write-Host "Testing PowerShell quoting behavior with isic-cli" -ForegroundColor Green +Write-Host "=" * 60 + +# First test if CLI is accessible +Write-Host "`nTesting CLI accessibility..." -ForegroundColor Cyan +try { + $null = isic metadata download --help 2>&1 + Write-Host "✅ CLI is accessible" -ForegroundColor Green +} catch { + Write-Host "❌ CLI not accessible: $($_.Exception.Message)" -ForegroundColor Red + exit 1 +} + +# Test 1: Unix-style quoting - show what PowerShell passes to the program +Write-Host "`nTest 1: Unix-style quoting 'diagnosis_3:`"Squamous cell carcinoma in situ`"'" -ForegroundColor Yellow +$query1 = 'diagnosis_3:"Squamous cell carcinoma in situ"' +Write-Host "PowerShell will pass this string to isic: $query1" +Write-Host "Command: isic metadata download --limit 1 (with -s '$query1')" + +# Test 2: Incorrect PowerShell quoting +Write-Host "`nTest 2: Incorrect PowerShell quoting `"diagnosis_3:\`"Squamous cell carcinoma in situ\`"`"" -ForegroundColor Yellow +$query2 = "diagnosis_3:`"Squamous cell carcinoma in situ`"" +Write-Host "PowerShell will pass this string to isic: $query2" +Write-Host "Command: isic metadata download --limit 1 (with -s `"$query2`")" + +# Test 3: Correct PowerShell quoting with doubled quotes +Write-Host "`nTest 3: Correct PowerShell doubled quotes 'diagnosis_3:`"`"Squamous cell carcinoma in situ`"`"'" -ForegroundColor Yellow +$query3 = 'diagnosis_3:""Squamous cell carcinoma in situ""' +Write-Host "PowerShell will pass this string to isic: $query3" +Write-Host "Command: isic metadata download --limit 1 (with -s '$query3')" + +# Test 4: Correct PowerShell quoting with backticks +Write-Host "`nTest 4: Correct PowerShell backticks `"diagnosis_3:\`"Squamous cell carcinoma in situ\`"`"" -ForegroundColor Yellow +$query4 = "diagnosis_3:`"Squamous cell carcinoma in situ`"" +Write-Host "PowerShell will pass this string to isic: $query4" +Write-Host "Command: isic metadata download --limit 1 (with -s `"$query4`")" + +# Test 5: Simple query without spaces +Write-Host "`nTest 5: Simple query 'age_approx:50'" -ForegroundColor Yellow +$query5 = 'age_approx:50' +Write-Host "PowerShell will pass this string to isic: $query5" +Write-Host "Command: isic metadata download --help (with -s '$query5')" + +Write-Host "`n" + "=" * 60 +Write-Host "Analysis:" -ForegroundColor Cyan +Write-Host "- Test 1 passes: $query1" -ForegroundColor White +Write-Host "- Test 2 passes: $query2" -ForegroundColor White +Write-Host "- Test 3 passes: $query3" -ForegroundColor White +Write-Host "- Test 4 passes: $query4" -ForegroundColor White +Write-Host "- Test 5 passes: $query5" -ForegroundColor White +Write-Host "" +Write-Host "The issue occurs when the CLI validates these strings against the ISIC API." -ForegroundColor Yellow +Write-Host "For actual testing, use the GitHub Actions workflow which connects to the API." -ForegroundColor Yellow \ No newline at end of file diff --git a/test-unix-quoting.sh b/test-unix-quoting.sh new file mode 100755 index 0000000..22aa881 --- /dev/null +++ b/test-unix-quoting.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Bash script to test quoting behavior with isic-cli on Unix systems +# Run this in bash/zsh to see how quoting works on Unix + +echo "Testing Unix/Linux quoting behavior with isic-cli" +echo "============================================================" + +# Test 1: Standard Unix quoting - test with actual API call +echo +echo "Test 1: Standard Unix quoting 'diagnosis_3:\"Squamous cell carcinoma in situ\"'" +echo "Command: isic metadata download -s 'diagnosis_3:\"Squamous cell carcinoma in situ\"' --limit 1" +if isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 > /dev/null 2>&1; then + echo "Result: SUCCESS" +else + echo "Result: FAILED" +fi + +# Test 2: Double-quoted with escaped quotes +echo +echo "Test 2: Double-quoted with escapes \"diagnosis_3:\\\"Squamous cell carcinoma in situ\\\"\"" +echo "Command: isic metadata download -s \"diagnosis_3:\\\"Squamous cell carcinoma in situ\\\"\" --limit 1" +if isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1 > /dev/null 2>&1; then + echo "Result: SUCCESS" +else + echo "Result: FAILED" +fi + +# Test 3: Simple query without spaces +echo +echo "Test 3: Simple query 'age_approx:50'" +echo "Command: isic metadata download -s 'age_approx:50' --limit 1" +if isic metadata download -s 'age_approx:50' --limit 1 > /dev/null 2>&1; then + echo "Result: SUCCESS" +else + echo "Result: FAILED" +fi + +echo +echo "============================================================" +echo "Expected behavior on Unix/Linux:" +echo "- All tests should SUCCESS (standard quoting works fine)" +echo "If any test fails, it may be due to network issues or API availability." \ No newline at end of file