Skip to main content
err:user:bad_request:invalid_analytics_function
Example
{
  "meta": {
    "requestId": "req_4dgzrNP3Je5mU1tD"
  },
  "error": {
    "detail": "Function 'file' is not allowed",
    "status": 400,
    "title": "Bad Request",
    "type": "https://unkey.com/docs/errors/user/bad_request/invalid_analytics_function"
  }
}

What Happened?

Your query tried to use a function that’s blocked for security reasons! For security, only safe functions are allowed in analytics queries. Functions that could:
  • Read files from the server (file, executable)
  • Make network requests (url, remote)
  • Access external systems (mysql, postgresql, s3, hdfs)
  • Modify data or system state
…are all blocked.

How to Fix It

1. Use Allowed Functions

Stick to standard analytics functions:
SELECT file('/etc/passwd') FROM key_verifications_v1

2. Common Safe Functions

These are examples of allowed functions: Aggregate functions:
  • COUNT(), SUM(), AVG(), MIN(), MAX()
  • uniq(), groupArray()
Date/time functions:
  • now(), today(), yesterday()
  • toStartOfHour(), toStartOfDay(), toStartOfWeek()
  • toDate(), toDateTime()
String functions:
  • concat(), substring(), lower(), upper()
  • length(), position()
Mathematical functions:
  • round(), floor(), ceil()
  • abs(), sqrt(), pow()
Conditional functions:
  • if(), multiIf()
  • CASE WHEN ... THEN ... END

3. Remove Dangerous Functions

SELECT file('/path/to/file') FROM key_verifications_v1

Commonly Blocked Functions

These functions are blocked for security:
FunctionWhy Blocked
file(), executable()File system access
url(), remote()Network requests
mysql(), postgresql(), mongodb()External database access
s3(), hdfs(), azureBlobStorage()External storage access
dictGet(), dictGetOrDefault()Dictionary access
Need a specific function that’s blocked? Contact support to discuss your use case - we may be able to safely enable it!