Validation errors
Every message on this page was produced by running safran profile check on a deliberately
broken profile. Find yours, read the fix. Paths are shown as /work/acme/safran.yaml.
Reading an error
A broken profile gives one of two shapes, depending on which validation step failed.
The profile schema failed (step one). The header names the file:
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- teams.0: Unrecognized key: "repo"
- (root): Unrecognized key: "langauges"
→ Fix the problems listed above; safran.example.yaml shows a complete profile.A connector's own schema failed (step two). The header counts the problems:
$ safran profile check
✘ The profile has 1 configuration problem:
- trackers.0.email_env: is required for Jira Cloud (the API token is used together with the account e-mail)
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.In both, each line is <path>: <message>. Paths are the keys of the file joined with dots;
list positions count from zero, so trackers.0 is the first tracker and teams.2.projects is
the projects of the third team. (root) is the top level of the file.
Step two only runs when step one passes. Fix the first kind and run the command again: more problems may appear. Within a step, everything wrong is reported at once.
The command exits with code 1. With --json the error is one document, with the lines in
problems:
$ safran profile check --json
{
"error": {
"code": "PLUGIN_CONFIG_INVALID",
"message": "The profile has 1 configuration problem:\n - trackers.0.email_env: is required for Jira Cloud (the API token is used together with the account e-mail)",
"hint": "Fix these entries in the profile. `safran plugins` lists the available types and their fields.",
"problems": [
"trackers.0.email_env: is required for Jira Cloud (the API token is used together with the account e-mail)"
]
}
}The four codes
| Code | Raised when | Typical cause |
|---|---|---|
PROFILE_INVALID | The file is missing, is not YAML, or does not match the profile schema | A misspelled top-level key, a duplicate id, a project under two trackers |
PLUGIN_NOT_FOUND | No plugin handles an entry's type, or a plugins: module cannot be loaded or exports no plugin | A misspelled type, a wrong module path |
PLUGIN_CONFIG_INVALID | An entry does not match its connector's schema | A misspelled field, a missing required field, a secret pasted into an _env field |
FORBIDDEN | The profile lists plugins: and the caller did not allow loading them | A safran.yaml picked up from the current directory |
When step two finds several problems, the error carries their common code. If the problems
have different codes (an unknown type on one entry and a bad field on another), the code is
PLUGIN_CONFIG_INVALID.
None of these involves the network or a token. A missing token is not a validation error; it is
AUTH_MISSING, raised when a connector is first used. See Secrets.
PROFILE_INVALID
The profile is not there
$ safran profile check
✘ Profile not found: /work/acme/safran.yaml
→ Create one with `safran init`, or copy safran.example.yaml to safran.yaml.The CLI looked for safran.yaml in the directory you ran it from. Change to the profile's
directory, pass --profile <file>, or set SAFRAN_PROFILE. If there is no profile yet,
safran init writes one.
The file is not valid YAML
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- invalid YAML: YAML Parse error: Unexpected token
→ Fix the problems listed above; safran.example.yaml shows a complete profile.The parser could not read the file at all, most often because of indentation: the keys of one list item must line up. The message carries no line number, so check the block you edited last.
trackers:
- id: jira
type: jira # one space short: must align with `id`An unknown key
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- teams.0: Unrecognized key: "repo"
- (root): Unrecognized key: "langauges"
→ Fix the problems listed above; safran.example.yaml shows a complete profile.The top level, languages, code, and the entries of teams and glossary accept only the
keys in the reference. Here langauges should be languages and a
team's repo should be repos. An unknown key is never ignored: a typo that silently did
nothing would be worse.
version, company or languages has the wrong form
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- version: Invalid input: expected 1
- company: use lowercase letters, digits and dashes
- languages.tickets: Too big: expected string to have exactly 2 characters
→ Fix the problems listed above; safran.example.yaml shows a complete profile.| Line | Fix |
|---|---|
version: Invalid input: expected 1 | Write version: 1. |
company: use lowercase letters, digits and dashes | Acme Inc becomes acme or acme-inc. |
languages.tickets: Too big: expected string to have exactly 2 characters | Use the two-letter code: tr, not turkish. |
languages.code: Invalid input: expected string, received undefined | When languages is present it needs both tickets and code. |
glossary.0.code: Too small: expected array to have >=1 items | A glossary entry needs at least one code word. |
A duplicate id, team name or glossary term
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- trackers: duplicate tracker id "jira"
- glossary: duplicate glossary term "IADE"
→ Fix the problems listed above; safran.example.yaml shows a complete profile.Give each tracker, each code host and each doc source its own id, and each team its own
name. The id is your label, not the type: two Jira sites can be jira-cloud and
jira-legacy.
Glossary terms are compared after case folding, so İade and IADE are the same term. Merge
their code lists into one entry.
A project listed under two trackers
$ safran profile check
✘ /work/acme/safran.yaml is not a valid profile:
- trackers.1.projects: project "pay" is also listed under tracker "jira"; a ticket key must map to one tracker
- teams.0.projects: project "WEB" is not listed under any tracker
→ Fix the problems listed above; safran.example.yaml shows a complete profile.A key such as PAY-1423 is sent to the tracker that lists PAY, so a project can belong to
one tracker only. The comparison ignores case: pay and PAY collide. Remove the project from
one of the two trackers. If both systems really use the same key, list it under the tracker
that should answer for bare keys, and address the other one as <trackerId>:<ref>.
A team's project is not under any tracker
The second line above. teams[].projects may only name projects that some tracker lists under
its projects. Either add WEB to the tracker that has it, or correct the team. This rule is
skipped while no tracker lists any project.
PLUGIN_NOT_FOUND
An unknown connector type
$ safran profile check
✘ The profile has 2 configuration problems:
- trackers.0 (jira): No tracker plugin handles type "jirra" (Available tracker types: azure-boards, github-issues, jira, linear.)
- code.hosts.0 (azure): No code-host plugin handles type "azure" (Available code-host types: azure-repos, github, gitlab, local.)
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.type selects the plugin and must be one of the listed names exactly. The name in parentheses
after the path is the entry's id. The Azure DevOps types are azure-boards for work items and
azure-repos for code. safran plugins prints every type with a description; if the type
belongs to a plugin of your own, it is missing from plugins:.
A plugin module that cannot be loaded
$ safran profile check
✘ Could not load plugin module "./plugins/acme-tracker.ts": ResolveMessage: Cannot find module './plugins/acme-tracker.ts' from '/work/acme'
→ Entries under `plugins:` are package names or paths relative to the profile file.A path under plugins: is resolved against the directory of the profile file, not against
where you run the command. Check that the file exists there. A package name must be installed
where it can be resolved from that directory.
A module that exports no plugin
$ safran profile check
✘ Plugin module "./plugins/empty.ts" exports no Safran plugin
→ Export the result of defineTracker / defineCodeHost / defineDocSource / defineEmbedder.The module loaded, but none of its exports is a plugin. A plugin must be exported by name, or inside an exported array. See Writing plugins.
PLUGIN_CONFIG_INVALID
email_env is missing for Jira Cloud
$ safran profile check
✘ The profile has 1 configuration problem:
- trackers.0.email_env: is required for Jira Cloud (the API token is used together with the account e-mail)
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.The jira type defaults to deployment: cloud, where an API token only works together with
the account's e-mail address. Add email_env: JIRA_EMAIL and set that variable. For Jira Data
Center, set deployment: datacenter instead. The Confluence doc source has the same rule. See
Jira.
A token pasted into an _env field
$ safran profile check
✘ The profile has 2 configuration problems:
- trackers.0.email_env: must be the NAME of an environment variable (e.g. JIRA_TOKEN), not the secret itself
- trackers.0.token_env: must be the NAME of an environment variable (e.g. JIRA_TOKEN), not the secret itself
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields._env fields hold a variable name in upper case (JIRA_TOKEN), and the value goes into your
shell or the .env next to the profile. If a real token was saved into the file, treat it as
leaked and rotate it. See Secrets.
A URL with credentials
$ safran profile check
✘ The profile has 1 configuration problem:
- trackers.0.url: must be a plain http(s) URL without credentials, query string or fragment
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.Write the base URL only (https://acme.atlassian.net). A user name, a password, a ?query or
a #fragment is rejected. Credentials go through the _env fields.
~ in a local path
$ safran profile check
✘ The profile has 1 configuration problem:
- code.hosts.0.path: `~` is not expanded; write an absolute path, or a path relative to the profile file
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.A plugin does not read your home directory, so ~/acme means nothing to it. Write
/work/acme/repos, or a path relative to the profile file such as ./repos. See
Local directories.
A misspelled field
$ safran profile check
✘ The profile has 3 configuration problems:
- code.hosts.0.organization: Invalid input: expected string, received undefined
- code.hosts.0: Unrecognized key: "organisation"
- embeddings: Unrecognized key: "modle"
→ Fix these entries in the profile. `safran plugins` lists the available types and their fields.A misspelled required field shows up twice: once as the unknown key that was written, once as
the required key that is now missing. Read the pair together: organisation should be
organization. The fields of each type are on its page under
Connectors.
FORBIDDEN: plugins of a profile you did not name
$ safran profile check
✘ safran.yaml lists plugin modules (./plugins/acme-tracker.ts), and it was picked up from the current directory, not named by you
→ Plugin modules run as code on this machine. If you trust this profile, name it (--profile safran.yaml) or pass --allow-plugins; otherwise remove its `plugins:` entries.This is not a mistake in the file. Loading a module listed under plugins: runs its code, and a
safran.yaml that merely happens to be in the directory you are in (a repository you just
cloned, for example) is not a reason to run code. The CLI therefore loads profile plugins only
when you have said which profile you mean:
safran profile check --profile safran.yaml # you named it
safran profile check --allow-plugins # you trust the one that was foundSetting SAFRAN_PROFILE counts as naming it. If you did not expect the profile to list
plugins, read the listed modules before allowing them.
In the SDK the switch is allowProfilePlugins. It defaults to true, because code that passes
a profile to createSafran chose that profile; a program that picks a profile up on the user's
behalf should pass false.
Checking a profile in code
createSafran runs the same two steps and throws the same errors. Branch on code; the lines
are in details.problems:
import { createSafran, isSafranError } from "@safran/core";
try {
await using safran = await createSafran({
profile: {
version: 1,
company: "acme",
trackers: [{ id: "jira", type: "jira", url: "https://acme.atlassian.net", token_env: "JIRA_TOKEN" }],
},
});
console.log(`valid: ${safran.profile.company}`);
} catch (error) {
if (!isSafranError(error)) throw error;
console.error(error.code); // PLUGIN_CONFIG_INVALID
const problems = error.details?.problems;
if (Array.isArray(problems)) for (const problem of problems) console.error(`- ${String(problem)}`);
// - trackers.0.email_env: is required for Jira Cloud (the API token is used together with the account e-mail)
}To check only the profile schema, without building connectors, use parseProfile from
@safran/profile; it throws PROFILE_INVALID with the same details.problems. An inline
profile is called "the inline profile" in the message instead of a file name.
Not validation errors, but seen at the same time
| Message | What it is |
|---|---|
! … are not set; the connectors that use them will fail when called. | A warning of a valid profile. Set the variables; see Secrets. |
! Low-confidence team mappings to confirm by hand: Mobile | A warning of a valid profile. Check the team and delete confidence: low. |
✘ A tracker plugin for type "jira" is registered more than once | INVALID_INPUT: a module under plugins: exports a plugin whose type already exists. Rename the plugin's type. |
✘ Environment variable JIRA_TOKEN is not set | AUTH_MISSING, from a command that used the connector. |
Errors lists every error code of the SDK.