ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(windows): evaluate model readiness paths literally (#8148)
Vaibhav Srivastava9b1eb117622a
diff --git a/.github/workflows/lint-powershell.yml b/.github/workflows/lint-powershell.ymlindex 6ac83fdd6..f9e272957 100644--- a/.github/workflows/lint-powershell.yml+++ b/.github/workflows/lint-powershell.yml@@ -299,6 +299,15 @@ jobs:shell: pwshrun: ./tests/test-windows-model-activation.ps1+ - name: Windows Model Readiness Literal Path Contract (PowerShell 7)+ shell: pwsh+ run: ./tests/test-windows-model-readiness-literalpath.ps1++ - name: Windows Model Readiness Literal Path Contract (Windows PowerShell)+ if: runner.os == 'Windows'+ shell: powershell+ run: ./tests/test-windows-model-readiness-literalpath.ps1+- name: Windows Owner Public URL Carry Contractshell: pwshrun: ./tests/test-windows-public-url-carry.ps1diff --git a/ods/installers/windows/lib/llm-endpoint.ps1 b/ods/installers/windows/lib/llm-endpoint.ps1index 222f0c81d..09779e196 100644--- a/ods/installers/windows/lib/llm-endpoint.ps1+++ b/ods/installers/windows/lib/llm-endpoint.ps1@@ -248,7 +248,8 @@ function Test-WindowsLlmModelReadiness {if (-not [string]::IsNullOrWhiteSpace($GgufFile)) {$modelPath = Join-Path (Join-Path (Join-Path $InstallDir "data") "models") $GgufFile$result.ModelFile = $modelPath- $result.FileExists = Test-Path $modelPath+ # Test-Path $modelPath treats brackets as wildcards; evaluate -LiteralPath.+ $result.FileExists = Test-Path -LiteralPath $modelPath -PathType Leaf} else {# No local GGUF configured (e.g. cloud/managed backend) -> file gate N/A.$result.FileExists = $truediff --git a/ods/tests/test-windows-model-readiness-literalpath.ps1 b/ods/tests/test-windows-model-readiness-literalpath.ps1new file mode 100644index 000000000..c7d5e62a7--- /dev/null+++ b/ods/tests/test-windows-model-readiness-literalpath.ps1@@ -0,0 +1,53 @@+$ErrorActionPreference = "Stop"++# Contract: Test-WindowsLlmModelReadiness must evaluate model paths literally.+# Paths containing bracket characters (e.g., directory names with square brackets+# or quantized model tags like model[q4].gguf) must not fail Test-Path as wildcards.++$root = Split-Path -Parent $PSScriptRoot+. (Join-Path $root 'installers/windows/lib/llm-endpoint.ps1')++function Assert($condition, $message) {+ if (-not $condition) { throw $message }+}++# Mock completion handler returning valid content+function Invoke-WebRequest {+ param($Method, $Uri, $Headers, $ContentType, $Body, $TimeoutSec, [switch]$UseBasicParsing, $ErrorAction)+ return [pscustomobject]@{+ StatusCode = 200+ Content = '{"choices":[{"message":{"content":"OK"}}]}'+ }+}++$testRoot = Join-Path ([IO.Path]::GetTempPath()) "ods-bracket[models]-$([Guid]::NewGuid().ToString('N'))"+try {+ $modelsDir = Join-Path (Join-Path $testRoot "data") "models"+ [System.IO.Directory]::CreateDirectory($modelsDir) | Out-Null++ # Case 1: Bracketed directory path with standard model file+ $modelFile1 = "qwen-test.gguf"+ Set-Content -LiteralPath (Join-Path $modelsDir $modelFile1) -Value "model-data"++ $endpoint = @{ ChatCompletionsUrl = "http://localhost:8080/v1/chat/completions" }+ $res1 = Test-WindowsLlmModelReadiness -Endpoint $endpoint -InstallDir $testRoot -GgufFile $modelFile1 -TimeoutSec 5+ Assert $res1.FileExists "Model in bracketed directory must be detected on disk (FileExists=true)"+ Assert $res1.Ok "Model readiness in bracketed directory must pass (Ok=true)"++ # Case 2: Bracketed model filename+ $modelFile2 = "qwen[q4_k_m].gguf"+ Set-Content -LiteralPath (Join-Path $modelsDir $modelFile2) -Value "model-data"++ $res2 = Test-WindowsLlmModelReadiness -Endpoint $endpoint -InstallDir $testRoot -GgufFile $modelFile2 -TimeoutSec 5+ Assert $res2.FileExists "Model with bracketed filename must be detected on disk (FileExists=true)"+ Assert $res2.Ok "Model readiness with bracketed filename must pass (Ok=true)"++ # Case 3: Genuinely missing file must still fail+ $resMissing = Test-WindowsLlmModelReadiness -Endpoint $endpoint -InstallDir $testRoot -GgufFile "genuinely-missing.gguf" -TimeoutSec 5+ Assert (-not $resMissing.FileExists) "Missing file must report FileExists=false"+ Assert (-not $resMissing.Ok) "Missing file must report Ok=false"++ Write-Output "Windows LLM model readiness literal path contract OK"+} finally {+ Remove-Item -LiteralPath $testRoot -Recurse -Force -ErrorAction SilentlyContinue+}