Skip to main content

PKU559: Function Metadata Not Found

Error Message

[PKU559] No function metadata found for '[functionName]'.

What Went Wrong

Pikku couldn't find metadata for the specified function. This usually means the function isn't wrapped with pikkuFunc() or hasn't been properly registered during the inspection phase.

How to Fix

Ensure Function is Wrapped with pikkuFunc

import { pikkuFunc } from '#pikku'

// ❌ Wrong: Regular function
const myHandler = async (input: { name: string }) => {
return { message: `Hello ${input.name}` }
}

// ✅ Correct: Wrapped with pikkuFunc
const myHandler = pikkuFunc(async (input: { name: string }) => {
return { message: `Hello ${input.name}` }
})

Make Sure Function is Exported

// ❌ Wrong: Not exported
const myHandler = pikkuFunc(async () => {
/* ... */
})

// ✅ Correct: Exported
export const myHandler = pikkuFunc(async () => {
/* ... */
})

Verify Function is in Scanned Directory

Check your pikku.config.json:

{
"srcDirectories": ["src"], // Make sure your function file is in here
"outDir": ".pikku"
}

Common Scenarios

HTTP Routes

import { wireHTTP } from '@pikku/core/http'
import { pikkuFunc } from '#pikku'

// Define the function first
export const getUsers = pikkuFunc(async () => {
return { users: [] }
})

// Then wire it
wireHTTP({
method: 'get',
route: '/api/users',
func: getUsers, // Must reference a pikkuFunc
})

Channel Handlers

import { addChannel } from '@pikku/core/channel'
import { pikkuFunc } from '#pikku'

// All handlers must be pikkuFuncs
export const handleMessage = pikkuFunc(async (msg: string) => {
return { echo: msg }
})

addChannel({
name: 'chat',
onMessageWiring: {
message: handleMessage, // Must be a pikkuFunc
},
})

MCP Tools

import { addMCPTool } from '@pikku/core/mcp'
import { pikkuFunc } from '#pikku'

export const calculateSum = pikkuFunc(
async ({ a, b }: { a: number; b: number }) => {
return { sum: a + b }
}
)

addMCPTool({
name: 'sum',
description: 'Adds two numbers',
func: calculateSum, // Must be a pikkuFunc
})

Debugging Steps

  1. Verify the function is wrapped with pikkuFunc()
  2. Check exports - Make sure the function is exported
  3. Run npx pikku prebuild to regenerate types
  4. Check file location - Ensure it's in a scanned directory

Common Mistakes

  • Using regular async functions instead of pikkuFunc
  • Defining the function inline in the wiring call
  • Not exporting the function
  • Typos in the function name reference
  • PKU236 - Missing Function Property