Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ jobs:
run: ./scripts/build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/luma_ai-node'
if: |-
github.repository == 'stainless-sdks/luma_ai-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/luma_ai-node'
if: |-
github.repository == 'stainless-sdks/luma_ai-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.20.0"
".": "1.20.1"
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 1.20.1 (2026-03-07)

Full Changelog: [v1.20.0...v1.20.1](https://github.com/lumalabs/lumaai-node/compare/v1.20.0...v1.20.1)

### Bug Fixes

* **client:** preserve URL params already embedded in path ([bd71801](https://github.com/lumalabs/lumaai-node/commit/bd718018365cbd54350cb25fec6d4696dd4a4142))
* **docs/contributing:** correct pnpm link command ([35ace89](https://github.com/lumalabs/lumaai-node/commit/35ace89e0c1a84d1d241dbbd48e6f6b879b8f5f6))


### Chores

* **ci:** skip uploading artifacts on stainless-internal branches ([0948668](https://github.com/lumalabs/lumaai-node/commit/0948668b08784afc6d6308b959d7c0812fe5e9f1))
* **internal:** codegen related update ([16451fa](https://github.com/lumalabs/lumaai-node/commit/16451fa5bdd71a79efc12586a717ae9e24cb794a))
* **internal:** move stringifyQuery implementation to internal function ([c8f608f](https://github.com/lumalabs/lumaai-node/commit/c8f608f2b3b52db38d2e2fccdc4a262ea4538d14))
* **test:** do not count install time for mock server timeout ([1905253](https://github.com/lumalabs/lumaai-node/commit/1905253f076eaa16e2d3ef16919b913ee4ccc11b))
* update mock server docs ([f625696](https://github.com/lumalabs/lumaai-node/commit/f625696b39864ebef7090f47bf9513a017efa08c))

## 1.20.0 (2026-02-08)

Full Changelog: [v1.19.1...v1.20.0](https://github.com/lumalabs/lumaai-node/compare/v1.19.1...v1.20.0)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ $ yarn link lumaai
# With pnpm
$ pnpm link --global
$ cd ../my-package
$ pnpm link -global lumaai
$ pnpm link --global lumaai
```

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
$ npx prism mock path/to/your/openapi.yml
$ ./scripts/mock
```

```sh
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lumaai",
"version": "1.20.0",
"version": "1.20.1",
"description": "The official TypeScript library for the LumaAI API",
"author": "LumaAI <support+api@lumalabs.ai>",
"types": "dist/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
# Wait for server to come online (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
exit 1
fi
echo -n "."
sleep 0.1
done
Expand Down
31 changes: 10 additions & 21 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
APIConnectionTimeoutError,
APIUserAbortError,
} from './error';
import { stringifyQuery } from './internal/utils/query';
import {
kind as shimsKind,
type Readable,
Expand Down Expand Up @@ -523,32 +524,20 @@ export abstract class APIClient {
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));

const defaultQuery = this.defaultQuery();
if (!isEmptyObj(defaultQuery)) {
query = { ...defaultQuery, ...query } as Req;
const pathQuery = Object.fromEntries(url.searchParams);
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
query = { ...pathQuery, ...defaultQuery, ...query } as Req;
}

if (typeof query === 'object' && query && !Array.isArray(query)) {
url.search = this.stringifyQuery(query as Record<string, unknown>);
url.search = this.stringifyQuery(query);
}

return url.toString();
}

protected stringifyQuery(query: Record<string, unknown>): string {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new LumaAIError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
protected stringifyQuery(query: object | Record<string, unknown>): string {
return stringifyQuery(query);
}

async fetchWithTimeout(
Expand Down Expand Up @@ -630,9 +619,9 @@ export abstract class APIClient {
}
}

// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
// just do what it says, but otherwise calculate a default
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
// If the API asks us to wait a certain amount of time, do what it says.
// Otherwise calculate a default.
if (timeoutMillis === undefined) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Malformed Retry-After causes zero-backoff retry loop

High Severity

The guard if (timeoutMillis === undefined) no longer protects against NaN or negative timeoutMillis values. When a Retry-After header contains a non-numeric, non-date string, Date.parse() returns NaN, making timeoutMillis NaN. Since NaN !== undefined, the default backoff is skipped and sleep(NaN) is called, which setTimeout treats as 0ms. Similarly, a past date produces a negative value, also treated as 0ms. Both cases cause immediate retries with zero backoff, potentially hammering the server in a tight loop.

Additional Locations (1)

Fix in Cursor Fix in Web

const maxRetries = options.maxRetries ?? this.maxRetries;
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
}
Expand Down
23 changes: 23 additions & 0 deletions src/internal/utils/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { LumaAIError } from '../../error';

/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
export function stringifyQuery(query: object | Record<string, unknown>) {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new LumaAIError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.20.0'; // x-release-please-version
export const VERSION = '1.20.1'; // x-release-please-version
6 changes: 2 additions & 4 deletions tests/stringifyQuery.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { LumaAI } from 'lumaai';

const { stringifyQuery } = LumaAI.prototype as any;
import { stringifyQuery } from 'lumaai/internal/utils/query';

describe(stringifyQuery, () => {
for (const [input, expected] of [
Expand All @@ -15,7 +13,7 @@ describe(stringifyQuery, () => {
'e=f',
)}=${encodeURIComponent('g&h')}`,
],
]) {
] as const) {
it(`${JSON.stringify(input)} -> ${expected}`, () => {
expect(stringifyQuery(input)).toEqual(expected);
});
Expand Down