generated from kestra-io/plugin-template
-
Couldn't load subscription status.
- Fork 3
Open
Labels
area/backendNeeds backend code changesNeeds backend code changesbugSomething isn't workingSomething isn't working
Description
Describe the issue
Even tho I have an appropriate amount of authorisation, it still says I am getting an unauthorised error while using disableFlowsByIds. Other than this, other methods are working with the current Auth.
Also, I see a common pattern: "XByIds" is not working. Might be this specfic function is creating the issue?
let idWithNamespace = [new KestraIoKestraSdk.IdWithNamespace({
id: "test_flow_1",
namespace: "test.qa.example"
})];Error Logs
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
Error: Unauthorized
at Request.callback (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:883:15)
at /Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:1126:20
at IncomingMessage.<anonymous> (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/parsers/json.js:22:7)
at IncomingMessage.emit (node:events:520:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
status: 401,
response: <ref *1> Response {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
res: IncomingMessage {
_events: [Object],
_readableState: [ReadableState],
_maxListeners: undefined,
socket: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
joinDuplicateHeaders: undefined,
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 401,
statusMessage: 'Unauthorized',
client: [Socket],
_consuming: false,
_dumped: false,
req: [ClientRequest],
_eventsCount: 4,
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/delete/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
Symbol(shapeMode): true,
Symbol(kCapture): false,
Symbol(kHeaders): [Object],
Symbol(kHeadersCount): 8,
Symbol(kTrailers): null,
Symbol(kTrailersCount): 0
},
request: Request {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
_enableHttp2: false,
_agent: false,
_formData: null,
method: 'DELETE',
url: 'http://localhost:8021/api/v1/pradumnasaraf/flows/delete/by-ids',
_header: [Object],
header: [Object],
writable: true,
_redirects: 0,
_maxRedirects: 5,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
_timeout: 60000,
_responseTimeout: 0,
_uploadTimeout: 0,
_data: [Array],
req: [ClientRequest],
protocol: 'http:',
host: 'localhost:8021',
_endCalled: true,
_callback: [Function (anonymous)],
res: [IncomingMessage],
_resBuffered: true,
response: [Circular *1],
called: true,
Symbol(shapeMode): false,
Symbol(kCapture): false
},
req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 4,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
_header: 'DELETE /api/v1/pradumnasaraf/flows/delete/by-ids HTTP/1.1\r\n' +
'Host: localhost:8021\r\n' +
'Accept-Encoding: gzip, deflate\r\n' +
'Authorization: Basic I_removed_due_to_github_secrets_alert\r\n' +
'User-Agent: OpenAPI-Generator/1.0.0/Javascript\r\n' +
'Content-Type: application/json\r\n' +
'Accept: application/json\r\n' +
'Content-Length: 4\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'DELETE',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/api/v1/pradumnasaraf/flows/delete/by-ids',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
Symbol(shapeMode): false,
Symbol(kCapture): false,
Symbol(kBytesWritten): 0,
Symbol(kNeedDrain): false,
Symbol(corked): 0,
Symbol(kChunkedBuffer): [],
Symbol(kChunkedLength): 0,
Symbol(kSocket): [Socket],
Symbol(kOutHeaders): [Object: null prototype],
Symbol(errored): null,
Symbol(kHighWaterMark): 65536,
Symbol(kRejectNonStandardBodyWrites): false,
Symbol(kUniqueHeaders): null
},
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/delete/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
body: {
message: 'Unauthorized',
logref: null,
path: null,
_links: [Object],
_embedded: {}
},
files: undefined,
buffered: true,
headers: {
'content-type': 'application/json',
date: 'Wed, 22 Oct 2025 10:59:30 GMT',
'content-length': '243',
connection: 'close'
},
header: {
'content-type': 'application/json',
date: 'Wed, 22 Oct 2025 10:59:30 GMT',
'content-length': '243',
connection: 'close'
},
statusCode: 401,
status: 401,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error: Error: cannot DELETE /api/v1/pradumnasaraf/flows/delete/by-ids (401)
at Response.toError (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/response.js:98:13)
at ResponseBase._setStatusProperties (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/response-base.js:119:48)
at new Response (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/response.js:44:8)
at Request._emitResponse (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:930:18)
at /Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:1126:42
at IncomingMessage.<anonymous> (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/parsers/json.js:22:7)
at IncomingMessage.emit (node:events:520:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
status: 401,
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/delete/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
method: 'DELETE',
path: '/api/v1/pradumnasaraf/flows/delete/by-ids'
},
created: false,
accepted: false,
noContent: false,
badRequest: false,
unauthorized: true,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'application/json',
links: {},
setEncoding: [Function: bound ],
redirects: [],
pipe: [Function (anonymous)],
Symbol(shapeMode): false,
Symbol(kCapture): false
}
}
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
API called successfully. Returned data: [object Object]
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
API called successfully. Returned data: [object Object]
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
API called successfully. Returned data: [object Object]
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
API called successfully. Returned data: [object Object]
➜ test-js-sdk git:(main) ✗ npm run start
> test-js-sdk@1.0.0 start
> node index.js
Error: Unauthorized
at Request.callback (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:883:15)
at /Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:1126:20
at IncomingMessage.<anonymous> (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/parsers/json.js:22:7)
at IncomingMessage.emit (node:events:520:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
status: 401,
response: <ref *1> Response {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
res: IncomingMessage {
_events: [Object],
_readableState: [ReadableState],
_maxListeners: undefined,
socket: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
joinDuplicateHeaders: undefined,
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 401,
statusMessage: 'Unauthorized',
client: [Socket],
_consuming: false,
_dumped: false,
req: [ClientRequest],
_eventsCount: 4,
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/disable/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
Symbol(shapeMode): true,
Symbol(kCapture): false,
Symbol(kHeaders): [Object],
Symbol(kHeadersCount): 8,
Symbol(kTrailers): null,
Symbol(kTrailersCount): 0
},
request: Request {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
_enableHttp2: false,
_agent: false,
_formData: null,
method: 'POST',
url: 'http://localhost:8021/api/v1/pradumnasaraf/flows/disable/by-ids',
_header: [Object],
header: [Object],
writable: true,
_redirects: 0,
_maxRedirects: 5,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
_timeout: 60000,
_responseTimeout: 0,
_uploadTimeout: 0,
_data: [Array],
req: [ClientRequest],
protocol: 'http:',
host: 'localhost:8021',
_endCalled: true,
_callback: [Function (anonymous)],
res: [IncomingMessage],
_resBuffered: true,
response: [Circular *1],
called: true,
Symbol(shapeMode): false,
Symbol(kCapture): false
},
req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 4,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
_header: 'POST /api/v1/pradumnasaraf/flows/disable/by-ids HTTP/1.1\r\n' +
'Host: localhost:8021\r\n' +
'Accept-Encoding: gzip, deflate\r\n' +
'Authorization: Basic cHNhcmFmQGtlc3RyYS5pbzpLZXN0cmFAMTIz\r\n' +
'User-Agent: OpenAPI-Generator/1.0.0/Javascript\r\n' +
'Content-Type: application/json\r\n' +
'Accept: application/json\r\n' +
'Content-Length: 4\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/api/v1/pradumnasaraf/flows/disable/by-ids',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
Symbol(shapeMode): false,
Symbol(kCapture): false,
Symbol(kBytesWritten): 0,
Symbol(kNeedDrain): false,
Symbol(corked): 0,
Symbol(kChunkedBuffer): [],
Symbol(kChunkedLength): 0,
Symbol(kSocket): [Socket],
Symbol(kOutHeaders): [Object: null prototype],
Symbol(errored): null,
Symbol(kHighWaterMark): 65536,
Symbol(kRejectNonStandardBodyWrites): false,
Symbol(kUniqueHeaders): null
},
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/disable/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
body: {
message: 'Unauthorized',
logref: null,
path: null,
_links: [Object],
_embedded: {}
},
files: undefined,
buffered: true,
headers: {
'content-type': 'application/json',
date: 'Wed, 22 Oct 2025 11:23:58 GMT',
'content-length': '244',
connection: 'close'
},
header: {
'content-type': 'application/json',
date: 'Wed, 22 Oct 2025 11:23:58 GMT',
'content-length': '244',
connection: 'close'
},
statusCode: 401,
status: 401,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error: Error: cannot POST /api/v1/pradumnasaraf/flows/disable/by-ids (401)
at Response.toError (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/response.js:98:13)
at ResponseBase._setStatusProperties (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/response-base.js:119:48)
at new Response (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/response.js:44:8)
at Request._emitResponse (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:930:18)
at /Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/index.js:1126:42
at IncomingMessage.<anonymous> (/Users/kestra/Dev/test-js-sdk/node_modules/superagent/lib/node/parsers/json.js:22:7)
at IncomingMessage.emit (node:events:520:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
status: 401,
text: '{"message":"Unauthorized","logref":null,"path":null,"_links":{"self":{"href":"/api/v1/pradumnasaraf/flows/disable/by-ids","templated":false,"profile":null,"deprecation":null,"title":null,"hreflang":null,"type":null,"name":null}},"_embedded":{}}',
method: 'POST',
path: '/api/v1/pradumnasaraf/flows/disable/by-ids'
},
created: false,
accepted: false,
noContent: false,
badRequest: false,
unauthorized: true,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'application/json',
links: {},
setEncoding: [Function: bound ],
redirects: [],
pipe: [Function (anonymous)],
Symbol(shapeMode): false,
Symbol(kCapture): false
}
}Reproducibility
Create the flow below the Flow:
id: test_flow_1
namespace: test.qa.example
tasks:
- id: hello
type: io.kestra.plugin.core.log.Log
message: Hello from flow test_flow_1! 👋 After creating, also, replace the namespace and tenant accordingly.
Then, run the code below.
JS Code
import 'dotenv/config';
import KestraIoKestraSdk from '@kestra-io/kestra-sdk';
// Initialize Kestra SDK client
const defaultClient = KestraIoKestraSdk.ApiClient.instance;
// Configure API endpoint
defaultClient.basePath = process.env.KESTRA_API_URL;
// Configure HTTP basic authorization (if using basicAuth)
const basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = process.env.KESTRA_USERNAME;
basicAuth.password = process.env.KESTRA_PASSWORD;
// Create API instance
const apiInstance = new KestraIoKestraSdk.FlowsApi();
// Configuration
const tenant = process.env.KESTRA_TENANT;
let idWithNamespace = [new KestraIoKestraSdk.IdWithNamespace({
id: "test_flow_1",
namespace: "test.qa.example"
})]; // [IdWithNamespace] | A list of tuple flow ID and namespace as flow identifiers
apiInstance.disableFlowsByIds(tenant, idWithNamespace, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});Environment
- Kestra Version: develop
Metadata
Metadata
Assignees
Labels
area/backendNeeds backend code changesNeeds backend code changesbugSomething isn't workingSomething isn't working