fix: api-key field names, dataset readiness check, punycode warning#14
Merged
Conversation
Three bugs/improvements that all surfaced from a real workflow run.
1. Fix api-key parsing
GET /v1/apps/{id}/api-keys returns `{ api_key, api_key_2 }` per the
OpenAPI schema, but the action was reading `{ primary, secondary }`,
so smoke tests bailed with `Cannot run runtime probes: no API key
returned for app …` immediately after a successful deploy. Update
`getApiKeys` to return `{ api_key, api_key_2 }` and select the
primary (or the secondary as a fallback).
2. Add dataset readiness check
After the deployment reports `succeeded` and the runtime answers
`isSpiceReady()`, poll `GET /v1/datasets?status=true` (per
https://spiceai.org/docs/api/HTTP/get-datasets) until every dataset
leaves the `initializing` state. Fail immediately if any dataset
enters `error`, surfacing the `error_message` so the user knows
which dataset is broken. New input `dataset-ready-timeout-seconds`
(default 300, set to 0 to skip), new `datasets` action output, and
a "Datasets" table in the GitHub job step summary. Status comparison
is case-insensitive so the action handles both the lowercase values
the public docs list and the PascalCase values the OSS runtime emits
in its OpenAPI examples.
3. Stop the DEP0040 punycode warning
`@spiceai/spice → node-fetch@2 → whatwg-url@5 → tr46@0.0.3` all
`require("punycode")`, which Node resolves to its deprecated
built-in. Install the userland `punycode@^2` package and add an
esbuild `--alias:punycode=…` flag so the bundle ships the userland
implementation instead.
Tests: 90 passing (up from 83). New cases cover api-key field-name
parsing, the runtime dataset poll loop (success / error / timeout /
no-op), and the deploy orchestration paths for both successful and
failing dataset checks.
There was a problem hiding this comment.
Pull request overview
Fixes a deployment-action regression where API keys were never parsed, adds a post-deploy dataset readiness gate to avoid probing an incompletely loaded runtime, and removes the Node DEP0040 punycode deprecation warning from the bundled action.
Changes:
- Parse
/v1/apps/{id}/api-keysresponse fields as{ api_key, api_key_2 }and propagate through deploy flow. - Add runtime dataset polling via
GET /v1/datasets?status=true, new inputdataset-ready-timeout-seconds, new outputdatasets, and step-summary reporting. - Bundle userland
punycodevia esbuild aliasing to suppressDEP0040warnings.
Reviewed changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/api.ts | Updates getApiKeys return shape to match the API response fields. |
| src/deploy.ts | Runs “post-deploy checks” (dataset readiness + probes) and returns datasets in deploy result. |
| src/runtime.ts | Adds dataset fetch + polling logic and a dedicated DatasetReadinessError. |
| src/inputs.ts | Adds datasetReadyTimeoutSeconds input parsing with default and validation. |
| src/main.ts | Exposes datasets as an action output and renders a datasets table in the step summary. |
| action.yml | Documents new input/output and defaults for dataset readiness checking. |
| tests/runtime.test.ts | Adds coverage for dataset fetch/poll behavior and error/timeout paths. |
| tests/deploy.test.ts | Updates API key mocks and adds dataset readiness integration tests. |
| package.json / package-lock.json | Adds punycode dependency and esbuild alias in the build script. |
| README.md | Documents new input/output in user-facing docs. |
| CHANGELOG.md | Records the new dataset readiness feature and API key parsing fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Explicitly classify dataset statuses into ok/error/pending buckets so `shuttingdown` and any unrecognized values are treated as still-pending rather than slipping through as a false-positive "loaded". Only `ready`/`disabled`/`refreshing` count as terminal-ok; only `error` short-circuits with `DatasetReadinessError`. Timeout messages now include each non-terminal-ok dataset's status so the user can tell `initializing` from `shuttingdown` from a typo. - Make dataset readiness failures always fatal once the check is opted in (`dataset-ready-timeout-seconds > 0`), independent of `fail-on-test-error` (which only governs runtime-probe results). Match action.yml/README/CHANGELOG to that behavior. The opt-out is `dataset-ready-timeout-seconds: 0`. - Add deploy + runtime tests covering each new path: terminal-ok values beyond `ready`, `shuttingdown`/unknown handling, and the fail-on-test-error-false-but-dataset-error-still-fatal case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three issues that all came out of a real failed run on the
lukekim/homeworkflow:```
Using app "home" (id=4573).
PUT /v1/apps/4573 tags={...}
…
status: in_progress → succeeded
##[group]Run 1 runtime probe(s)
##[error]Cannot run runtime probes: no API key returned for app 4573.
```
… plus the persistent
(node:NNNN) [DEP0040] DeprecationWarning: The 'punycode' module is deprecatedwarning every workflow has been printing.1. Fix
getApiKeysfield names (the actual blocker)`GET /v1/apps/{id}/api-keys` returns `{ api_key, api_key_2 }` per the OpenAPI schema, but the action was reading `{ primary, secondary }`. Both fields were always undefined → smoke tests bailed every run with "no API key returned". Updated `SpiceApiClient.getApiKeys` and the deploy code that consumes it.
2. Dataset readiness check (
/v1/datasets?status=true)Spice runtime can report `succeeded` for the deployment while datasets are still loading or in an error state. After `isSpiceReady()` succeeds, the action now polls `GET /v1/datasets?status=true` until every dataset leaves `initializing`, fails immediately on `error`, and surfaces each dataset's status in the step summary.
Status comparison is case-insensitive — the public docs list lowercase values but the OSS runtime examples emit PascalCase, so we normalize.
New input: `dataset-ready-timeout-seconds` (default `300`, `0` skips). New action output: `datasets` (JSON array of `{ name, status, from?, error?, error_message? }`). New step-summary table.
3. `DEP0040` punycode deprecation warning
The transitive chain `@spiceai/spice → node-fetch@2 → whatwg-url@5 → tr46@0.0.3` calls `require("punycode")`, which Node resolves to the deprecated built-in. Installed the userland `punycode@^2` package and added `--alias:punycode=./node_modules/punycode/punycode.js` to the esbuild build script. The rebuilt bundle now bundles the userland implementation; running `node dist/index.js` no longer prints the warning.
Test plan
Out of scope / docs