Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Error Array Errors #239

Open
joncrain opened this issue Nov 12, 2024 · 0 comments
Open

Empty Error Array Errors #239

joncrain opened this issue Nov 12, 2024 · 0 comments

Comments

@joncrain
Copy link

The response error values of many commands do not accept an empty array. For instance, with the rTRInitSessions, we have this error when creating the session:

// initiating code block
  console.log('Init RTR Session')
  const session = await client.realTimeResponse.rTRInitSession(
    {
      deviceId: crowdstrikeId,
      origin: '',
      queueOffline: true,
    },
    600,
  )

// error
Error getting value: 38 | function DomainInitResponseWrapperFromJSONTyped(json, ignoreDiscriminator) {
39 |     if (json == null) {
40 |         return json;
41 |     }
42 |     return {
43 |         errors: json["errors"].map(MsaAPIError_1.MsaAPIErrorFromJSON),
                          ^
TypeError: null is not an object (evaluating 'json.errors.map')
      at DomainInitResponseWrapperFromJSONTyped (crowdstrike-falcon/dist/models/DomainInitResponseWrapper.js:43:22)
      at fulfilled (crowdstrike-falcon/dist/runtime.js:18:58)

It is successful when updating the DomainInitResponseWrapperFromJSONTyped function to:

export function DomainInitResponseWrapperFromJSONTyped(json: any, ignoreDiscriminator: boolean): DomainInitResponseWrapper {
    if (json == null) {
        return json;
    }
    return {
        errors: Array.isArray(json["errors"]) ? json["errors"].map(MsaAPIErrorFromJSON) : [],
        meta: MsaMetaInfoFromJSON(json["meta"]),
        resources: (json["resources"] as Array<any>).map(DomainInitResponseFromJSON),
    };
}

Logging the response for this shows that the error array is empty:

// code to get responses
    async rTRInitSession(body: DomainInitRequest, timeout?: number, timeoutDuration?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DomainInitResponseWrapper> {
        const response = await this.rTRInitSessionRaw({ body: body, timeout: timeout, timeoutDuration: timeoutDuration }, initOverrides);
        console.log("Full response:", response);
        try {
            const value = await response.value();
            console.log("Response value:", value);
            return value;
        } catch (error) {
            console.error("Error getting value:", error);
            throw error;
        }
    }
// responses
Full response: JSONApiResponse {
  raw: Response (16.57 KB) {
    ok: true,
    url: "https://api.crowdstrike.com/real-time-response/entities/sessions/v1?timeout=600",
    status: 201,
    statusText: "Created",
    headers: Headers {
      "date": "Tue, 12 Nov 2024 18:06:03 GMT",
      "content-type": "application/json",
      "transfer-encoding": "chunked",
      "connection": "keep-alive",
      "content-encoding": "gzip",
      "strict-transport-security": "max-age=31536000; includeSubDomains",
      "server": "nginx",
      "x-cs-region": "us-1",
      "x-cs-traceid": "456baeeb-0c53-4e41-8aee",
      "x-ratelimit-limit": "6000",
      "x-ratelimit-remaining": "5983",
    },
    redirected: false,
    bodyUsed: false,
    Blob (16.57 KB)
  },
  transformer: [Function],
  value: [Function: value],
}
Response value: {
  errors: [],
  meta: {
    pagination: undefined,
    poweredBy: "empower-api",
    queryTime: 3.8983302,
    traceId: "456baeeb-0c53-4e41-8aee",
    writes: undefined,
  },
  resources: [
    {
      createdAt: 2024-11-06T21:56:00.021Z,
      existingAidSessions: 1,
...

There are many of these (157 from a search for the json error) that don't look like they are handling this correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant