Skip to content

solavrc/looker-unicode-issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Handling Unicode Characters in Looker Extensions

Problem Overview

When a Looker extension receives responses containing Unicode characters (especially non-Latin characters like Japanese or Chinese) from a backend API, issues occur with the Looker extension proxy.

POST https://{YOUR_ORG_SUBDOMAIN}.cloud.looker.com/api/internal/extension/external_api_proxy/{YOUR_PROJECT_NAME}::{YOUR_EXTENSION_NAME}

500 Internal Server Error
{error: "Uh oh! Something went wrong."}

This problem occurs when using the serverProxy method to make requests from the extension to a backend API that returns multibyte Unicode characters.

Solution

To solve this problem, we've adopted the following approach:

  1. Base64 encode response data from the backend
  2. Decode the Base64 data in the frontend for display

Implementation Details

This repository is a minimal configuration sample to reproduce the issue. It provides three API endpoints:

  1. /api/english - Returns English text (works normally)
  2. /api/japanese - Returns Japanese text directly (issues occur)
  3. /api/japanese-base64 - Returns Base64 encoded Japanese text (the solution)

Demo Environment Setup

Prerequisites

  • Google Cloud account
  • Google Cloud CLI installation (Installation guide)
  • Node.js and npm
  • Administrator access to a Looker instance

Deployment Instructions

1. Backend Deployment (Google Cloud Run)

# Navigate to the backend directory
cd backend

# Build Docker image and upload to container registry
gcloud builds submit --tag gcr.io/[PROJECT_ID]/looker-unicode-backend .

# Deploy to Cloud Run service
gcloud run deploy looker-unicode-backend \
  --image gcr.io/[PROJECT_ID]/looker-unicode-backend \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

After deployment completes, the service URL will be displayed. Make note of this URL:

Service [looker-unicode-backend] revision [looker-unicode-backend-00001-xxx] has been deployed and is serving 100 percent of traffic.
Service URL: https://looker-unicode-backend-[random-string].run.app

2. Frontend Build

2.1 Setting Environment Variables

# Navigate to the frontend directory
cd frontend

# Create .env file
echo "API_SERVER_URL=https://looker-unicode-backend-[random-string].run.app" > .env

2.2 Running the Build

# Install dependencies
npm install

# Production build
npm run build

This will generate a bundle.js file in the root directory of the repository.

3. Deploying to Looker

To deploy the Looker extension, follow the steps in the official documentation. The basic steps are as follows:

  1. Log in to your Looker instance and create a new LookML project
  2. Create a manifest.lkml file with the following content:
project_name: "${YOUR_LOOKER_PROJECT_NAME}" # your looker project name

application: looker-unicode-issue {
  label: "Looker Unicode Issue"
  file: "bundle.js"
  entitlements: {
    core_api_methods: ["run_inline_query", "me", "all_connections"]
    external_api_urls: ["https://${YOUR_CLOUD_RUN_URL}.run.app"] # your backend (cloud run) url
  }
}
  1. Upload the bundle.js file (generated during the build) to your Looker project
  2. Validate the LookML, commit changes, and deploy to production
  3. Enable the extension and access it from the Looker main menu by selecting "Extensions" → "Looker Unicode Issue"

For detailed instructions, refer to the Looker official documentation "Building a Looker extension".

Releases

No releases published

Packages

No packages published