> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Missing source preview for a deployed scorer

> Inspect a deployed scorer with no source preview, understand why it can still run, and identify what to check before contacting support.

> [!NOTE]
>
> **Applies to:**
>
> * Plan - Any
> * Deployment - Any
> *
> * Use case - Inspect a deployed code scorer whose source preview is missing.

A deployed code scorer can run even when its source code isn't visible. For an uploaded code bundle, Braintrust stores a reference to the executable bundle and an optional source preview. The preview is for display and isn't required to execute the scorer.

If a preview wasn't captured during upload, the UI can display **This function is too complex to edit in the UI** instead of source code. That message alone doesn't mean the scorer is broken.

## Inspect the stored definition

Use the [`bt` CLI](https://docs.braintrust.dev/reference/cli/quickstart) to retrieve the function object:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
bt functions view --id <function-id> --json
```

The command retrieves the latest version by default. Add `--version <version>` if you're investigating a specific deployed version. See [`bt functions view`](https://docs.braintrust.dev/reference/cli/functions#bt-functions-view) for all selectors.

For a bundled code scorer, check these fields in the returned function object:

| Field | Meaning |
| - | - |
| `function_data.type` | `code` identifies a code function. |
| `function_data.data.type` | `bundle` identifies an uploaded code bundle. |
| `function_data.data.bundle_id` | Reference to the executable bundle. |
| `function_data.data.preview` | Optional source preview used for display. If absent or empty, the function object has no preview to show. |

## Find the original source

Check the repository or files used to publish the scorer. A `bundle_id` identifies the executable bundle, but it isn't a source preview. Creating another scorer that references the same bundle does not restore a missing preview or reconstruct the original source files.

If you still have the source, keep it in version control. Preview availability depends on the upload workflow, so republishing alone doesn't guarantee a preview.

## Add a preview from known source

If you have the source that matches the deployed bundle, you can add it as a display-only preview:

1. Retrieve the latest function object with `bt functions view --id <function-id> --json`.
2. Copy the complete `function_data` object and set `function_data.data.preview` to the source code as a JSON string. Preserve the other fields, including `bundle_id`, `location`, and `runtime_context`.
3. Use [Partially update function](https://docs.braintrust.dev/api-reference/functions/partially-update-function.md) to send the updated object in the request body's `function_data` field to `PATCH /v1/function/{function_id}`.
4. Retrieve the latest definition again to confirm the preview was saved, then refresh the scorer page to view it.

This adds a preview without replacing the executable bundle. It doesn't recover lost source code.

If you need help investigating a missing preview, [contact Braintrust support](mailto:support@braintrust.dev) with:

* The function ID and the version you inspected.
* The original publish command and CLI or SDK version, if known.
* The returned `function_data` object, with sensitive source or configuration values removed.

If execution also fails, include the exact invocation error. A missing preview alone doesn't establish why execution failed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.