looker-open-source / dashboard-summarization

MIT License
17 stars 12 forks source link

websocket-service error #15

Open satonos opened 1 month ago

satonos commented 1 month ago

Hi, I would like to help me about the error that was happend. This error was happend on local development env when click "generate" of Looker dashboard.

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON at JSON.parse () at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19) at successSteps (node:internal/deps/undici/undici:5555:27) at fullyReadBody (node:internal/deps/undici/undici:1665:9) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async specConsumeBody (node:internal/deps/undici/undici:5564:7) at async throwErrorIfNotOK (C:\Looker-extension-framework\dashboard-summarization\websocket-service\src\node_modules\@google-cloud\vertexai\build\src\functions\post_fetch_processing.js:30:27) at async generateContentStream (C:\Looker-extension-framework\dashboard-summarization\websocket-service\src\node_modules\@google-cloud\vertexai\build\src\functions\generate_content.js:90:5) at async Socket. (C:\Looker-extension-framework\dashboard-summarization\websocket-service\src\index.js:178:31)

ryan-gould-accenture commented 1 month ago

Hi Santonos,

Based on the log it looks like an issue in your index file when you pass the prompt and it doesn't like your '<' character. Without knowing more and assuming that you have not changed the queryPrompt text my guess would be that the bad value comes from your ${context} variable and that something in your dashboard contains that '<' character that is being read into your prompt.

satonos commented 1 month ago

Hi @ryan-gould-accenture ,

Thank you for advicing. Based on the logs, it seems that the error is caused by loading in HTML format, but there are no changes from the original code and the cause is unknown. Do you know any solutions?

Listening on:  5000
initial transport websocket
Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: true,
    requestIncludesCredentials: true,
    type: 'default',
    status: 404,
    timingInfo: {
      startTime: 8430.9682,
      redirectStartTime: 0,
      redirectEndTime: 0,
      postRedirectStartTime: 8430.9682,
      finalServiceWorkerStartTime: 0,
      finalNetworkResponseStartTime: 0,
      finalNetworkRequestStartTime: 0,
      endTime: 0,
      encodedBodySize: 1159,
      decodedBodySize: 1159,
      finalConnectionTimingInfo: null
    },
    cacheState: '',
    statusText: 'Not Found',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [ URL {} ],
    body: { stream: undefined }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(6) {
      'content-type' => [Object],
      'referrer-policy' => [Object],
      'content-length' => [Object],
      'date' => [Object],
      'alt-svc' => [Object],
      'connection' => [Object]
    },
    [Symbol(headers map sorted)]: null
  }
}
undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
LukaFontanilla commented 1 month ago

@satonos, where is this happening? When running locally or when deploying? That error is from the authentication and call to the Gemini SDK. Auth likely failed.

If you are deploying via the terraform make sure to set the PROJECT & REGION TF Variables. If hitting locally or when deploying manually with gloud run deploy you'll need to ensure the variables (your GCP Project ID and Region) at this line are set -> https://github.com/looker-open-source/dashboard-summarization/blob/71f7c371fe225af058cb1db05a9f310cbe0c31b4/websocket-service/src/index.js#L70

satonos commented 1 month ago

@LukaFontanilla Thank you for your guidance. I was able to successfully display the summary after making the changes you suggested in the local environment. However, I am unable to obtain any information after clicking the "Generate" button. I understand that a cookie error is occurring, but I believe that this is unrelated to the current issue. Could you please provide any advice regarding this matter? image