Skip to content

Commit 3905c3a

Browse files
committed
wip
1 parent 3072b15 commit 3905c3a

File tree

5 files changed

+341
-0
lines changed

5 files changed

+341
-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: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
# This should fail because PowerShell interprets the quotes differently
33+
isic metadata download -s 'diagnosis_3:"Squamous cell carcinoma in situ"' --limit 1
34+
35+
- name: Test incorrect PowerShell quoting (should also fail)
36+
id: incorrect-powershell
37+
shell: pwsh
38+
continue-on-error: true
39+
run: |
40+
# This is what users might try but still fails
41+
isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1
42+
43+
- name: Test correct PowerShell quoting with doubled quotes
44+
id: correct-powershell-doubled
45+
shell: pwsh
46+
continue-on-error: true
47+
run: |
48+
# This should work - doubled quotes inside single quotes
49+
isic metadata download -s 'diagnosis_3:""Squamous cell carcinoma in situ""' --limit 1
50+
51+
- name: Test correct PowerShell quoting with backticks
52+
id: correct-powershell-backticks
53+
shell: pwsh
54+
continue-on-error: true
55+
run: |
56+
# This should work - backtick escaping
57+
isic metadata download -s "diagnosis_3:`"Squamous cell carcinoma in situ`"" --limit 1
58+
59+
- name: Test simple query without spaces (should always work)
60+
id: simple-query
61+
shell: pwsh
62+
run: |
63+
# This should always work regardless of shell
64+
isic metadata download -s 'age_approx:50' --limit 1
65+
66+
- name: Verify test results
67+
shell: pwsh
68+
run: |
69+
Write-Host "Test Results Summary:"
70+
Write-Host "Unix-style quoting exit code: ${{ steps.unix-style.outcome }}"
71+
Write-Host "Incorrect PowerShell quoting exit code: ${{ steps.incorrect-powershell.outcome }}"
72+
Write-Host "Correct PowerShell doubled quotes exit code: ${{ steps.correct-powershell-doubled.outcome }}"
73+
Write-Host "Correct PowerShell backticks exit code: ${{ steps.correct-powershell-backticks.outcome }}"
74+
Write-Host "Simple query exit code: ${{ steps.simple-query.outcome }}"
75+
76+
# We expect the first two to fail and the last three to succeed
77+
if ("${{ steps.unix-style.outcome }}" -eq "failure" -and
78+
"${{ steps.incorrect-powershell.outcome }}" -eq "failure" -and
79+
"${{ steps.correct-powershell-doubled.outcome }}" -eq "success" -and
80+
"${{ steps.correct-powershell-backticks.outcome }}" -eq "success" -and
81+
"${{ steps.simple-query.outcome }}" -eq "success") {
82+
Write-Host "✅ PowerShell quoting behavior is as expected"
83+
exit 0
84+
} else {
85+
Write-Host "❌ Unexpected PowerShell quoting behavior"
86+
exit 1
87+
}
88+
89+
test-cmd-quoting:
90+
runs-on: windows-latest
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up Python
95+
uses: actions/setup-python@v4
96+
with:
97+
python-version: "3.11"
98+
99+
- name: Install dependencies
100+
run: |
101+
pip install --upgrade pip
102+
pip install -e .
103+
shell: cmd
104+
105+
- name: Test quoting in Command Prompt
106+
shell: cmd
107+
run: |
108+
REM Test basic quoting in cmd.exe
109+
isic metadata download -s "diagnosis_3:\"Squamous cell carcinoma in situ\"" --limit 1
110+
111+
- name: Test simple query in Command Prompt
112+
shell: cmd
113+
run: |
114+
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)