This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new 9d2fcc8 Add alert for invalid Daffodil version requests
9d2fcc8 is described below
commit 9d2fcc88e57beb063a3645a2d0c814fdb5ede693
Author: Shane Dell <[email protected]>
AuthorDate: Tue Nov 18 11:55:25 2025 -0500
Add alert for invalid Daffodil version requests
- Pull and parse https://daffodil.apache.org/doap.rdf to find if provided
daffodil version is valid or not.
- Bump to macos-15 in CI since macos-13 are being deprecated
Closes #1476
---
.github/workflows/CI.yml | 6 ++++-
.github/workflows/nightly.yml | 4 +++-
src/daffodilDebugger/daffodilJars.ts | 45 +++++++++++++++++++++++++++++++++++-
src/daffodilDebugger/utils.ts | 9 ++++++++
4 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index b9eed13..533472d 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -110,9 +110,13 @@ jobs:
matrix:
java_distribution: [temurin]
java_version: [8, 11, 17, 21]
- os: [macos-13, ubuntu-22.04, windows-2022]
+ os: [macos-15, ubuntu-22.04, windows-2022]
node: ["20.19.4", "22.14.0"]
vscode: ["1.90.0", "stable"] # v1.90.0 is the first version of VSCode
to use Node 20
+ exclude:
+ # java 8 not available on macos-15
+ - os: macos-15
+ java_version: 8
fail-fast: false # don't immediately fail all other jobs if a single job
fails
runs-on: ${{ matrix.os }}
defaults:
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 958fb5f..5765087 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -28,7 +28,7 @@ jobs:
matrix:
os:
[
- macos-13,
+ macos-15,
ubuntu-22.04,
windows-2022,
macos-latest,
@@ -41,6 +41,8 @@ jobs:
java_version: [8, 11, 17, 21]
exclude:
# java 8 not available on latest macos
+ - os: macos-15
+ java_version: 8
- os: macos-latest
java_version: 8
fail-fast: false # don't immediately fail all other jobs if a single job
fails
diff --git a/src/daffodilDebugger/daffodilJars.ts
b/src/daffodilDebugger/daffodilJars.ts
index 346d007..dcef241 100644
--- a/src/daffodilDebugger/daffodilJars.ts
+++ b/src/daffodilDebugger/daffodilJars.ts
@@ -20,6 +20,7 @@ import * as fs from 'fs'
import * as vscode from 'vscode'
import { outputChannel } from '../adapter/activateDaffodilDebug'
import { downloadAndExtract } from '../utils'
+import { parseStringPromise } from 'xml2js'
/**
* Only the default version of Daffodil is bundled with the extension, all
other versions are
@@ -46,16 +47,55 @@ export async function checkIfDaffodilJarsNeeded(
context.asAbsolutePath('./dist'),
`daffodil/apache-daffodil-${daffodilVersion}-bin`
)
+
if (fs.existsSync(extensionPath)) {
outputChannel.appendLine(`[INFO] Using bundled Daffodil CLI JARs.`)
return extensionPath
}
+ // If not a valid daffodil version provided and it doesn't exist already in
cache then throw error
+ if (!(await checkIfValidDaffodilVersion(daffodilVersion))) {
+ throw new Error(
+ 'Invalid Daffodil Version provided. Make sure
dfdlDebugger.daffodilVersion is a valid version of Daffodil'
+ )
+ }
+
// downloadAndExtractToGlobalStorage only tries to download the Daffodil CLI
release file if
// the desired version's bin folder doesn't already exists.
return await downloadAndExtractToGlobalStorage(context, daffodilVersion)
}
+// Helper function to get the list of valid Daffodil versions
+async function getValidDaffodilVersions(): Promise<string[]> {
+ const url = 'https://daffodil.apache.org/doap.rdf'
+
+ const resp = await fetch(url)
+ if (!resp.ok) {
+ throw new Error(
+ `Failed to fetch DOAP RDF: ${resp.status} ${resp.statusText}`
+ )
+ }
+
+ const xmlText = await resp.text()
+ const data = await parseStringPromise(xmlText, { explicitArray: false })
+
+ const project = data['rdf:RDF']['Project']
+ const releases = project['release']
+
+ const releaseArray = Array.isArray(releases) ? releases : [releases]
+
+ return releaseArray
+ .filter((rel) => rel['Version']['name'] == 'Apache Daffodil') // only look
at Daffodil releases
+ .map((rel: any) => rel['Version']['revision'] ?? '')
+ .filter((s) => s != '') // make sure no empty strings are saved
+}
+
+// Helper function to check if the given daffodil version is a valid version
or not
+const checkIfValidDaffodilVersion = async (
+ daffodilVersion: string
+): Promise<boolean> =>
+ (await getValidDaffodilVersions()).includes(daffodilVersion)
+
export async function downloadAndExtractToGlobalStorage(
context: vscode.ExtensionContext,
daffodilVersion: string
@@ -75,7 +115,10 @@ export async function downloadAndExtractToGlobalStorage(
try {
await downloadAndExtract('Daffodil CLI JARs', url, destFolder)
} catch (err) {
- console.error(err)
+ /**
+ * If error hit trying to download and extract throw the error
+ */
+ throw `[ERROR] downloading and extracting Daffodil CLI JARs for
${daffodilVersion}: ${err}`
}
} else {
outputChannel.appendLine(
diff --git a/src/daffodilDebugger/utils.ts b/src/daffodilDebugger/utils.ts
index 6694a53..8b076d7 100644
--- a/src/daffodilDebugger/utils.ts
+++ b/src/daffodilDebugger/utils.ts
@@ -121,6 +121,15 @@ export async function runDebugger(
// Download the daffodil CLI jars if needed
const daffodilPath = await checkIfDaffodilJarsNeeded(dfdlVersion)
+ /**
+ * If 'error' returned from checkIfDaffodilJarsNeeded then there was an
error hit somewhere inside of that
+ * function, most likely downloading/extracting the JARS. Whenever any error
is hit from that function, the
+ * extension shouldn't run the debugger.
+ */
+ if (daffodilPath === 'error') {
+ return undefined
+ }
+
const artifact = daffodilArtifact(dfdlVersion)
const scriptPath = path.join(
rootPath,