Gotchas¶
These are the mistakes that bite most often when people extend KnowledgeLake, grouped by surface and roughly in order of how often they bite. Each one starts with what you see, then the cause and the fix. For an exact error text, see the Error message index.
At a glance
- The top three Routing values written only on documents, metadata values treated as numbers, and an API token missing one feature
- Also watch Behaviors run on the server in Start QC Task too; secret global variables are readable from workflow JavaScript; Jobs and RPA API filters with uneven case and time zone rules; event delivery gaps
- Each entry Symptom, cause, fix, link
Summary¶
Custom Step and workflow scripts¶
Every work item takes the default route¶
- Cause The script set the routing value on each document. Routes read work item metadata only.
- Fix Also write the value at the work item level:
builder.SetBatchMetadata("Index", "NeedsReview", "Yes"). Through the API, useUpsertWorkItemMetadata. - Related Workflow routes
A value you just set reads back as the old value¶
- Cause
buildercalls are queued and apply when the script ends.batchstill holds the values from the start of the run. - Fix Keep the new value in a variable. If you must read the applied result in the same run, call
builder.ApplyChanges(); it applies the queue and reloadsbatchandworkItem. - Related Custom Step reference
A loop skipped half the documents¶
- Cause
builder.ApplyChanges()inside a loop overbatch.Documents. It reloadsbatch, so the list your loop walks changes under it. - Fix Collect the document ids first, loop over that copy, and call
ApplyChanges()once after the loop, or not at all. - Related Custom Step reference
parseFloat returns NaN¶
- Cause Every metadata value is a string, and extracted amounts often keep
$,,or spaces. - Fix Strip them first:
parseFloat(String(value || "").replace(/[^0-9.\-]/g, "")) || 0. - Related Common JavaScript errors
A sample from the old help site does not run¶
- Cause Many old samples were written for Process Designer:
SetDocumentMetadata(bucket, key, value)with three arguments,logger,http, andContextwith a capital C. - Fix Use the current signatures in the Custom Step reference:
builder.SetDocumentMetadata(documentId, bucket, key, value). - Related Common JavaScript errors
Copying a document to another work item fails¶
- Symptom Copying a document into another work item fails with
Target work item does not exist. - Cause
CopyDocumentToWorkItemandMoveDocumentToWorkItemaccept only a work item that the same script created withbuilder.CreateWorkItem(name). - Fix Create the target in the script, or move documents into an existing work item from your own code through the API.
- Related Error message index
The release step finds no content type¶
- Symptom The release step says the document has no assigned content type.
- Cause Upload To Destination reads
General.DocTypeId(the content type's internal id). A key namedContentTypeorContentTypeIddoes not choose the destination. - Fix Use
builder.SetContentType(documentId, contentTypeId)in a Custom Step (it writes bothDocTypeIdandContentTypeId), or setGeneral.DocTypeIdwhen you add the document through the API. - Related Find where a released document landed
A secret value shows up in metadata or a log¶
- Symptom A secret global variable's value shows up in metadata, an event or a log.
- Cause Routes, step setting preprocessors and Custom Steps can read a secret variable's value. A script that copies it into metadata, a Custom Event property or a request body exposes it to everyone who can read those.
- Fix Use a secret only where it must go (for example an HTTP header in Call External API). Never write it to metadata or an event. Review scripts that read secrets.
- Related Workflow global variables
Index panel behaviors¶
A behavior changes values in a workflow step¶
- Symptom A behavior changes values in a workflow step that you did not expect.
- Cause Custom Behaviors also run on the server, with
context.app="worker"and an empty user. - Where The Index Your Documents, Run Indexing Behaviors and Start QC Task steps (Start QC Task runs them when Mark Valid Documents as Indexed is on, the default), and Search bulk edit.
- Fix Guard browser-only logic:
if (context.app === "worker") { return; }. Do not rely oncontext.usernameon the server. - Related Custom Behaviors introduction
The behavior sets nothing¶
- Symptom The behavior sets nothing and the field shows "Behavior Custom Behavior could not be fired."
- Cause The script uses
Contextwith a capital C (copied from old documentation), so it throwsReferenceError: Context is not defined. - Fix Use
context.username, all lowercase. Open the browser console (F12) to see the exact error. - Related Debugging Custom Index Behaviors
A lookup misses a value typed in another case¶
- Symptom A lookup finds nothing when the value is typed in another case.
- Cause Reported by customers: SQL lookups match case-sensitively.
- Fix Normalize the case of the key field in a behavior before the lookup runs.
- Related Debugging Custom Index Behaviors
Call External API and your own endpoint¶
Call External API fails at once¶
- Symptom The step fails at once with
Api domain is not valid. - Cause The URL points at
localhostor a private address. The step refuses it before it sends anything. - Fix Deploy the endpoint to a public HTTPS host first. Debug locally with a hard-coded work item id in a debug build.
- Related Debugging Call External API and functions
Call External API reports success, and nothing changed¶
- Cause Your endpoint caught an exception and still returned HTTP 200.
- Fix Return 4xx or 5xx on any failure. The step then fails, and
ApiResults.LastHttpStatusCodeholds your status code for a route. - Related Your own endpoint
The step timed out, but the function log shows success¶
- Cause The work took longer than the step's Timeout setting (0 means 15 minutes). The step stopped waiting; the function went on and finished.
- Fix Set the step timeout longer than the function's worst-case run time. Make the function faster, or split the work.
- Platform limits Keep the function under its platform limit. Azure Functions Consumption plan: 5 minutes by default for a run, and an HTTP-triggered function must answer within 230 seconds. API Gateway in front of Lambda: 29 seconds.
- Related Your own endpoint
The function ran twice and the values doubled¶
- Cause The step ran again (after a timeout, an error and a resubmit) and the code added to a value instead of setting it.
- Fix Upsert fixed values. Never append to a value or increment a counter based on what is there.
- Holds If the function releases a hold, treat
No hold was found for workitem {id}as "already done". - Related Your own endpoint
A PUT, PATCH or DELETE step fails¶
- Cause Call External API lists those verbs but runs only GET and POST.
- Fix Use POST. Put your own endpoint in between if the target needs another verb.
- Related Call External API
The function fails on its first call¶
- Symptom The function fails on its first call with
System.Linq, Version=8.0.0.0. - Cause An Azure Function on .NET 8 in-process without the setting that enables it.
- Fix App setting
FUNCTIONS_INPROC_NET8_ENABLED=1, in Azure and inlocal.settings.json. - Related Your own endpoint
The token is null in the debugger¶
- Cause Visual Studio or the terminal started before you set the environment variable.
- Fix Restart Visual Studio or the terminal after you set it.
- Related Authentication
REST API¶
Success: false and no message¶
- Cause Your code reads
Message, which does not exist. The text is inMessageKeyorMessages[].MessageKey. Behind it there is usually a missing token feature (HTTP 401). - Fix Print the HTTP status and
MessageKey. Add the feature to the token on Configuration > Services > API Access, or give the user the permission in Configuration > Permissions > API Access. - Related API introduction
HTTP 412 after a token rotation, or on some work items¶
- Symptom HTTP 412 after a token rotation, or on some work items only.
- Cause HTTP 412 is an application error, not an authentication error. A bad or deleted token gives HTTP 401.
- After a token change A 412 points at the rest of the request: the work item id, a document id, or the body.
- On some items only It often means a workflow step holds the work item at that moment.
- Fix Read
Messages[].MessageKey; the text afterRoot message:names the problem. For a locked work item, wait and retry with a growing delay. - Related Error message index
The API returns Id, the script uses DocumentId¶
- Cause The API projection names a document's id
Id. Custom Steps, routes and Liquid call itDocumentId. - Fix Map the names when you move code between surfaces.
- Related KWorkItem API reference
Testing in a browser runs as you, not as the token¶
- Cause A KnowledgeLake session cookie takes priority over the
TempIdentityTokenheader. - Fix Test from a script, a REST client or a private browser window.
- Related Authentication
The Intuitive AI API returns HTTP 401 with a valid token¶
- Cause The token does not have the feature named Manage Learn Fingerprints, which the Intuitive AI API uses.
- Fix Edit the token and select that feature.
- Related Authentication
QueryWorkState does not find a work item¶
- Symptom
QueryWorkStatedoes not find a work item you know exists. - Cause It returns only work items in workflows the token's user can run. A work item never sent to a workflow is not included.
- Filter
MetadataKeyFilterlooks only in theIndexbucket, with an exact value. - Fix Give the user Run permission on the workflow, or keep a list of the ids your code created.
- Related KWorkItem API reference
A job name finds runs but no history¶
- Cause
V1_JobsAPI/QueryForJobRunscomparesJobDisplayNamewithout case;QueryForJobHistoriescompares it with case. - Fix Filter history by
JobID(theJobIDfromQueryForJobRuns), not by name. - Related Jobs, RPA and Monitoring API
QueryForLatestRPATasks finds nothing or refuses a filter¶
- Symptom
QueryForLatestRPATasksreturns nothing for a time window, or refuses a filter. - Cause
LastUpdateTimeAfteris compared exactly as sent, with no conversion to or from UTC. ABotNameorAutomationthat matches nothing, or a blankProcess, is rejected, not ignored. - Fix Send the time in the zone the tasks were recorded in, or widen the window. Take bot and automation names from a previous result.
- Related Jobs, RPA and Monitoring API
Events¶
Events you expected never arrive¶
- Symptom Events you expected never arrive in your event store.
- Cause Several event families never reach a provider set up in the UI, even with every category ticked. Delivery is also best effort: events queued in a process that restarts are lost.
- Not delivered Insight, Tasks app actions, the class builders, Monitor RPA actions, upload profiles, Portal administration, Intuitive AI engine errors, Write Event API events and everything from the Tasks service.
- Fix Check the event's entry in the Events Dictionary before you build on it. For your own business events, use a Custom Event step. Do not treat a missing event as proof that nothing happened.
- Related Events and the Secondary Event Provider
A Custom Event step succeeds but no event arrives¶
- Cause The tenant has no Secondary Event Provider, its Custom category is unticked, or the step runs on the legacy worker (a Process Designer process), which does not forward custom events.
- Fix Open Configuration > Apps > Event Settings, edit the provider, and tick Custom. Use the step in a Workflow designer workflow.
- Related Custom Event step