Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.5 KB
Raw Blame
use serde_json::Error as JsonError;
use thiserror::Error;

/// Errors that can occur when validating a tool's schema.
#[derive(Debug, Error)]
pub enum ValidationError {
    /// The schema is missing required metadata (title or description).
    #[error("missing metadata")]
    MissingMetadata,
    /// Failed to serialize the schema to JSON.
    #[error("could not convert to json")]
    JsonSerialization(JsonError),
    /// The schema contains nested objects which are not supported.
    #[error("schema exceeds depth one - nested objects with properties are not allowed")]
    ExceedsDepthOne,
    /// The schema title is empty.
    #[error("title is empty")]
    EmptyTitle,
    /// The schema contains `oneOf` which is not supported for AI tools.
    #[error("schema must not have oneOf set. Do not use descriptions or /// on enum types.")]
    OneOf,
    /// Schema must be a serde_json::Value::Object
    #[error("schema must be a serde_json::Value::Object")]
    ExpectedObject,
    /// The schema contains a `$ref`, which means a recursive type survived
    /// inlining. Strict tool use cannot express recursive schemas.
    #[error(
        "schema contains $ref — recursive types cannot be inlined and are not supported by strict tool use"
    )]
    UnsupportedRef,
    /// An object's `additionalProperties` is not `false` — map types with
    /// arbitrary keys cannot be expressed in strict mode.
    #[error(
        "additionalProperties must be false — map types (e.g. HashMap) are not supported by strict tool use; use a Vec of key/value structs instead"
    )]
    AdditionalProperties,
    /// An `enum` contains object or array values; strict mode only allows
    /// primitive enum members.
    #[error("enum values must be primitives (string, number, bool, or null)")]
    ComplexEnum,
    /// The root of a tool input schema must be an object.
    #[error("tool input schema root must have type \"object\"")]
    RootNotObject,
    /// Providers reject composition keywords at the tool input root.
    #[error(
        "tool input schema root must not contain oneOf, anyOf, or allOf; put alternatives inside a named property instead of flattening them"
    )]
    RootComposition,
    /// A `$ref` loop runs only through required, non-nullable fields, so no
    /// finite value fits it; Gemini rejects the whole request.
    #[error(
        "schema has a $ref loop of required fields closing at {0}; make a field on the loop optional or nullable, or reach it through an array that may be empty"
    )]
    RequiredRefLoop(String),
}