Skip to content

Commit 4893b6a

Browse files
committed
wip
1 parent 3072b15 commit 4893b6a

File tree

5 files changed

+359
-0
lines changed

5 files changed

+359
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Debug PowerShell Quoting
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
debug-quoting:
9+
runs-on: windows-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.11"
17+
18+
- name: Install dependencies
19+
run: |
20+
pip install --upgrade pip
21+
pip install -e .
22+
shell: pwsh
23+
24+
- name: Test CLI accessibility
25+
shell: pwsh
26+
run: |
27+
Write-Host "Testing basic CLI functionality..."
28+
isic --help
29+
30+
- name: Test simple metadata query (no spaces)
31+
shell: pwsh
32+
run: |
33+
Write-Host "Testing simple query without spaces..."
34+
isic metadata download -s "age_approx:50" --limit 1
35+
36+
- name: Debug: Show what PowerShell passes for different quotes
37+
shell: pwsh
38+
run: |
39+
Write-Host "=== PowerShell Quoting Debug ==="
40+
41+
# Test 1: Single quotes around the whole thing
42+
$query1 = 'diagnosis_3:"Squamous cell carcinoma in situ"'
43+
Write-Host "Query 1 (single quotes): '$query1'"
44+
Write-Host "Length: $($query1.Length)"
45+
Write-Host "Characters: $($query1.ToCharArray() -join ', ')"
46+
47+
# Test 2: Double quotes with escaped inner quotes
48+
$query2 = "diagnosis_3:`"Squamous cell carcinoma in situ`""
49+
Write-Host "Query 2 (backtick escape): `"$query2`""
50+
Write-Host "Length: $($query2.Length)"
51+
Write-Host "Characters: $($query2.ToCharArray() -join ', ')"
52+
53+
# Test 3: Double quotes inside single quotes
54+
$query3 = 'diagnosis_3:""Squamous cell carcinoma in situ""'
55+
Write-Host "Query 3 (doubled quotes): '$query3'"
56+
Write-Host "Length: $($query3.Length)"
57+
Write-Host "Characters: $($query3.ToCharArray() -join ', ')"
58+
59+
- name: Test each quoting style with verbose output
60+
shell: pwsh
61+
run: |
62+
Write-Host "=== Testing actual commands ==="
63+
64+
Write-Host "`n1. Testing single quotes (Unix style):"
65+
try {
66+
isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 2>&1 | Tee-Object -Variable output1
67+
Write-Host "EXIT CODE: $LASTEXITCODE"
68+
} catch {
69+
Write-Host "EXCEPTION: $($_.Exception.Message)"
70+
}
71+
72+
Write-Host "`n2. Testing backtick escaping:"
73+
try {
74+
isic metadata download -s "diagnosis_3:`"Squamous cell carcinoma in situ`"" --limit 1 2>&1 | Tee-Object -Variable output2
75+
Write-Host "EXIT CODE: $LASTEXITCODE"
76+
} catch {
77+
Write-Host "EXCEPTION: $($_.Exception.Message)"
78+
}
79+
80+
Write-Host "`n3. Testing doubled quotes:"
81+
try {
82+
isic metadata download -s 'diagnosis_3:""Squamous cell carcinoma in situ""' --limit 1 2>&1 | Tee-Object -Variable output3
83+
Write-Host "EXIT CODE: $LASTEXITCODE"
84+
} catch {
85+
Write-Host "EXCEPTION: $($_.Exception.Message)"
86+
}
87+
88+
- name: Test with a known good diagnosis value
89+
shell: pwsh
90+
run: |
91+
Write-Host "=== Testing with a simpler diagnosis value ==="
92+
93+
# Try with a value that might not have special characters
94+
Write-Host "Testing with 'melanoma':"
95+
try {
96+
isic metadata download -s 'diagnosis_3:"melanoma"' --limit 1 2>&1
97+
Write-Host "EXIT CODE: $LASTEXITCODE"
98+
} catch {
99+
Write-Host "EXCEPTION: $($_.Exception.Message)"
100+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: PowerShell Quoting Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-powershell-quoting:
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install dependencies
22+
run: |
23+
pip install --upgrade pip
24+
pip install -e .
25+
shell: pwsh
26+
27+
- name: Test Unix-style quoting (should fail in PowerShell)
28+
id: unix-style
29+
shell: pwsh
30+
continue-on-error: true
31+
run: |
32+
Write-Host "Testing Unix-style quoting: 'diagnosis_3:`"Squamous cell carcinoma in situ`"'"
33+
$query = 'diagnosis_3:"Squamous cell carcinoma in situ"'
34+
Write-Host "PowerShell will pass: $query"
35+
isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1
36+
37+
- name: Test incorrect PowerShell quoting (should also fail)
38+
id: incorrect-powershell
39+
shell: pwsh
40+
continue-on-error: true
41+
run: |
42+
# This is what users might try but still fails
43+
isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1
44+
45+
- name: Test correct PowerShell quoting with doubled quotes
46+
id: correct-powershell-doubled
47+
shell: pwsh
48+
continue-on-error: true
49+
run: |
50+
# This should work - doubled quotes inside single quotes
51+
isic metadata download -s 'diagnosis_3:""Squamous cell carcinoma in situ""' --limit 1
52+
53+
- name: Test correct PowerShell quoting with backticks
54+
id: correct-powershell-backticks
55+
shell: pwsh
56+
continue-on-error: true
57+
run: |
58+
# This should work - backtick escaping
59+
isic metadata download -s "diagnosis_3:`"Squamous cell carcinoma in situ`"" --limit 1
60+
61+
- name: Test simple query without spaces (should always work)
62+
id: simple-query
63+
shell: pwsh
64+
run: |
65+
# This should always work regardless of shell
66+
isic metadata download -s 'age_approx:50' --limit 1
67+
68+
- name: Analyze test results
69+
shell: pwsh
70+
run: |
71+
Write-Host "=== Test Results Analysis ==="
72+
Write-Host "Unix-style quoting outcome: ${{ steps.unix-style.outcome }}"
73+
Write-Host "Incorrect PowerShell quoting outcome: ${{ steps.incorrect-powershell.outcome }}"
74+
Write-Host "Correct PowerShell doubled quotes outcome: ${{ steps.correct-powershell-doubled.outcome }}"
75+
Write-Host "Correct PowerShell backticks outcome: ${{ steps.correct-powershell-backticks.outcome }}"
76+
Write-Host "Simple query outcome: ${{ steps.simple-query.outcome }}"
77+
78+
Write-Host ""
79+
Write-Host "=== Analysis ==="
80+
81+
# Count successes and failures
82+
$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" }
83+
$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" }
84+
85+
Write-Host "Total successes: $($successes.Count)"
86+
Write-Host "Total failures: $($failures.Count)"
87+
88+
if ($successes.Count -eq 5) {
89+
Write-Host "🔍 All commands succeeded - this suggests either:"
90+
Write-Host " 1. PowerShell is handling all quoting styles correctly, OR"
91+
Write-Host " 2. The search validation is not strict enough to catch quoting issues"
92+
Write-Host "✅ This is actually good news - the quoting issue may not exist or be as severe as expected"
93+
} elseif ($failures.Count -eq 5) {
94+
Write-Host "❌ All commands failed - this suggests:"
95+
Write-Host " 1. Network/authentication issues, OR"
96+
Write-Host " 2. Invalid diagnosis value, OR"
97+
Write-Host " 3. CLI installation problems"
98+
} else {
99+
Write-Host "📊 Mixed results - this is the expected behavior if there's a real quoting issue"
100+
Write-Host " - Some quoting styles work, others don't"
101+
}
102+
103+
Write-Host ""
104+
Write-Host "This test run provides valuable data about PowerShell quoting behavior."
105+
Write-Host "All outcomes are informative and help us understand the real issue."
106+
107+
test-cmd-quoting:
108+
runs-on: windows-latest
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Set up Python
113+
uses: actions/setup-python@v4
114+
with:
115+
python-version: "3.11"
116+
117+
- name: Install dependencies
118+
run: |
119+
pip install --upgrade pip
120+
pip install -e .
121+
shell: cmd
122+
123+
- name: Test quoting in Command Prompt
124+
shell: cmd
125+
run: |
126+
REM Test basic quoting in cmd.exe
127+
isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1
128+
129+
- name: Test simple query in Command Prompt
130+
shell: cmd
131+
run: |
132+
isic metadata download -s "age_approx:50" --limit 1

test-diagnosis-values.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Test script to verify valid diagnosis values
3+
4+
echo "Testing various diagnosis values to find valid ones..."
5+
echo "============================================================"
6+
7+
# Test simple values first
8+
echo "Testing simple age query:"
9+
isic metadata download -s 'age_approx:50' --limit 1
10+
11+
echo
12+
echo "Testing diagnosis_3 with melanoma:"
13+
isic metadata download -s 'diagnosis_3:melanoma' --limit 1
14+
15+
echo
16+
echo "Testing diagnosis_3 with quotes around melanoma:"
17+
isic metadata download -s 'diagnosis_3:"melanoma"' --limit 1
18+
19+
echo
20+
echo "Testing if 'Squamous cell carcinoma in situ' is valid:"
21+
isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1
22+
23+
echo
24+
echo "Testing a different approach with diagnosis_2:"
25+
isic metadata download -s 'diagnosis_2:"Malignant melanocytic proliferations (Melanoma)"' --limit 1
26+
27+
echo
28+
echo "Getting help to see example queries:"
29+
isic metadata download --help | grep -A 10 -B 10 diagnosis

test-powershell-quoting.ps1

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# PowerShell script to test quoting behavior with isic-cli
2+
# Run this in PowerShell to see how different quoting styles behave
3+
4+
Write-Host "Testing PowerShell quoting behavior with isic-cli" -ForegroundColor Green
5+
Write-Host "=" * 60
6+
7+
# First test if CLI is accessible
8+
Write-Host "`nTesting CLI accessibility..." -ForegroundColor Cyan
9+
try {
10+
$null = isic metadata download --help 2>&1
11+
Write-Host "✅ CLI is accessible" -ForegroundColor Green
12+
} catch {
13+
Write-Host "❌ CLI not accessible: $($_.Exception.Message)" -ForegroundColor Red
14+
exit 1
15+
}
16+
17+
# Test 1: Unix-style quoting - show what PowerShell passes to the program
18+
Write-Host "`nTest 1: Unix-style quoting 'diagnosis_3:`"Squamous cell carcinoma in situ`"'" -ForegroundColor Yellow
19+
$query1 = 'diagnosis_3:"Squamous cell carcinoma in situ"'
20+
Write-Host "PowerShell will pass this string to isic: $query1"
21+
Write-Host "Command: isic metadata download --limit 1 (with -s '$query1')"
22+
23+
# Test 2: Incorrect PowerShell quoting
24+
Write-Host "`nTest 2: Incorrect PowerShell quoting `"diagnosis_3:\`"Squamous cell carcinoma in situ\`"`"" -ForegroundColor Yellow
25+
$query2 = "diagnosis_3:`"Squamous cell carcinoma in situ`""
26+
Write-Host "PowerShell will pass this string to isic: $query2"
27+
Write-Host "Command: isic metadata download --limit 1 (with -s `"$query2`")"
28+
29+
# Test 3: Correct PowerShell quoting with doubled quotes
30+
Write-Host "`nTest 3: Correct PowerShell doubled quotes 'diagnosis_3:`"`"Squamous cell carcinoma in situ`"`"'" -ForegroundColor Yellow
31+
$query3 = 'diagnosis_3:""Squamous cell carcinoma in situ""'
32+
Write-Host "PowerShell will pass this string to isic: $query3"
33+
Write-Host "Command: isic metadata download --limit 1 (with -s '$query3')"
34+
35+
# Test 4: Correct PowerShell quoting with backticks
36+
Write-Host "`nTest 4: Correct PowerShell backticks `"diagnosis_3:\`"Squamous cell carcinoma in situ\`"`"" -ForegroundColor Yellow
37+
$query4 = "diagnosis_3:`"Squamous cell carcinoma in situ`""
38+
Write-Host "PowerShell will pass this string to isic: $query4"
39+
Write-Host "Command: isic metadata download --limit 1 (with -s `"$query4`")"
40+
41+
# Test 5: Simple query without spaces
42+
Write-Host "`nTest 5: Simple query 'age_approx:50'" -ForegroundColor Yellow
43+
$query5 = 'age_approx:50'
44+
Write-Host "PowerShell will pass this string to isic: $query5"
45+
Write-Host "Command: isic metadata download --help (with -s '$query5')"
46+
47+
Write-Host "`n" + "=" * 60
48+
Write-Host "Analysis:" -ForegroundColor Cyan
49+
Write-Host "- Test 1 passes: $query1" -ForegroundColor White
50+
Write-Host "- Test 2 passes: $query2" -ForegroundColor White
51+
Write-Host "- Test 3 passes: $query3" -ForegroundColor White
52+
Write-Host "- Test 4 passes: $query4" -ForegroundColor White
53+
Write-Host "- Test 5 passes: $query5" -ForegroundColor White
54+
Write-Host ""
55+
Write-Host "The issue occurs when the CLI validates these strings against the ISIC API." -ForegroundColor Yellow
56+
Write-Host "For actual testing, use the GitHub Actions workflow which connects to the API." -ForegroundColor Yellow

test-unix-quoting.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Bash script to test quoting behavior with isic-cli on Unix systems
3+
# Run this in bash/zsh to see how quoting works on Unix
4+
5+
echo "Testing Unix/Linux quoting behavior with isic-cli"
6+
echo "============================================================"
7+
8+
# Test 1: Standard Unix quoting - test with actual API call
9+
echo
10+
echo "Test 1: Standard Unix quoting 'diagnosis_3:\"Squamous cell carcinoma in situ\"'"
11+
echo "Command: isic metadata download -s 'diagnosis_3:\"Squamous cell carcinoma in situ\"' --limit 1"
12+
if isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1 > /dev/null 2>&1; then
13+
echo "Result: SUCCESS"
14+
else
15+
echo "Result: FAILED"
16+
fi
17+
18+
# Test 2: Double-quoted with escaped quotes
19+
echo
20+
echo "Test 2: Double-quoted with escapes \"diagnosis_3:\\\"Squamous cell carcinoma in situ\\\"\""
21+
echo "Command: isic metadata download -s \"diagnosis_3:\\\"Squamous cell carcinoma in situ\\\"\" --limit 1"
22+
if isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1 > /dev/null 2>&1; then
23+
echo "Result: SUCCESS"
24+
else
25+
echo "Result: FAILED"
26+
fi
27+
28+
# Test 3: Simple query without spaces
29+
echo
30+
echo "Test 3: Simple query 'age_approx:50'"
31+
echo "Command: isic metadata download -s 'age_approx:50' --limit 1"
32+
if isic metadata download -s 'age_approx:50' --limit 1 > /dev/null 2>&1; then
33+
echo "Result: SUCCESS"
34+
else
35+
echo "Result: FAILED"
36+
fi
37+
38+
echo
39+
echo "============================================================"
40+
echo "Expected behavior on Unix/Linux:"
41+
echo "- All tests should SUCCESS (standard quoting works fine)"
42+
echo "If any test fails, it may be due to network issues or API availability."

0 commit comments

Comments
 (0)