Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cli/tests/ui/config_schema_additional_properties_schema.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
properties: {
token: { type: "string" },
},
additionalProperties: { type: "string" },
},
}
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_additional_properties_schema.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at additionalProperties:
`additionalProperties` must be a boolean in Amber config_schema
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_additional_properties_schema.json5:8:27]
7 │ },
8 │ additionalProperties: { type: "string" },
· ─────────┬────────
· ╰── invalid config definition here
9 │ },
╰────
9 changes: 9 additions & 0 deletions cli/tests/ui/config_schema_invalid_property_name.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
properties: {
agent_HF_TOKEN: { type: "string", secret: true },
},
},
}
15 changes: 15 additions & 0 deletions cli/tests/ui/config_schema_invalid_property_name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at properties.agent_HF_TOKEN: config property
name `agent_HF_TOKEN` is invalid; config property names must start with
a lowercase ASCII letter and contain only lowercase ASCII letters,
digits, and underscores; double underscores are not allowed. Uppercase
letters are not allowed; use `agent_hf_token` instead
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_invalid_property_name.json5:6:7]
5 │ properties: {
6 │ agent_HF_TOKEN: { type: "string", secret: true },
· ───────┬──────
· ╰── invalid config definition here
7 │ },
╰────
10 changes: 10 additions & 0 deletions cli/tests/ui/config_schema_invalid_required_name.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
properties: {
token: { type: "string" },
},
required: ["HF_TOKEN"],
},
}
15 changes: 15 additions & 0 deletions cli/tests/ui/config_schema_invalid_required_name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at required[0]: required config property name
`HF_TOKEN` is invalid; config property names must start with a lowercase
ASCII letter and contain only lowercase ASCII letters, digits, and
underscores; double underscores are not allowed. Uppercase letters are
not allowed; use `hf_token` instead
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_invalid_required_name.json5:8:16]
7 │ },
8 │ required: ["HF_TOKEN"],
· ─────┬────
· ╰── invalid config definition here
9 │ },
╰────
11 changes: 11 additions & 0 deletions cli/tests/ui/config_schema_invalid_type_keyword.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
properties: {
token: {
type: 42,
},
},
},
}
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_invalid_type_keyword.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at properties.token.type: 42 is not valid
under any of the schemas listed in the 'anyOf' keyword
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_invalid_type_keyword.json5:7:15]
6 │ token: {
7 │ type: 42,
· ─┬
· ╰── invalid config definition here
8 │ },
╰────
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_non_local_ref.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
$defs: {
token: { $anchor: "token", type: "string" },
},
properties: {
token: { $ref: "#token" },
},
},
}
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_non_local_ref.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at properties.token.$ref: `$ref` must be local
to the same config_schema (`#` or `#/...`)
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_non_local_ref.json5:9:22]
8 │ properties: {
9 │ token: { $ref: "#token" },
· ────┬───
· ╰── invalid config definition here
10 │ },
╰────
7 changes: 7 additions & 0 deletions cli/tests/ui/config_schema_properties_wrong_type.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
properties: [],
},
}
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_properties_wrong_type.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at properties: `properties` must be an object
in Amber config_schema, got array
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_properties_wrong_type.json5:5:17]
4 │ type: "object",
5 │ properties: [],
· ─┬
· ╰── invalid config definition here
6 │ },
╰────
7 changes: 7 additions & 0 deletions cli/tests/ui/config_schema_unknown_keyword.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
uiLabel: "Root config",
},
}
1 change: 1 addition & 0 deletions cli/tests/ui/config_schema_unknown_keyword.status
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
success
9 changes: 9 additions & 0 deletions cli/tests/ui/config_schema_unsupported_keyword.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
manifest_version: "0.1.0",
config_schema: {
type: "object",
patternProperties: {
".*": { type: "string" },
},
},
}
12 changes: 12 additions & 0 deletions cli/tests/ui/config_schema_unsupported_keyword.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Error: manifest::invalid_config_schema

× check failed
╰─▶ invalid config definition at patternProperties: unsupported
config_schema keyword `patternProperties`
╭─[<CARGO_MANIFEST_DIR>/tests/ui/config_schema_unsupported_keyword.json5:5:5]
4 │ type: "object",
5 │ patternProperties: {
· ────────┬────────
· ╰── invalid config definition here
6 │ ".*": { type: "string" },
╰────
2 changes: 2 additions & 0 deletions compiler/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod env;
mod error;
mod node;
mod profile;
mod schema;
mod template;

Expand All @@ -10,6 +11,7 @@ pub use env::{
};
pub use error::{ConfigError, Result};
pub use node::{ConfigNode, RootConfigTemplate, compose_config_template};
pub use profile::{ConfigSchemaProfileError, validate_config_schema_profile};
pub use schema::{
SchemaLeaf, SchemaLookup, SchemaPresence, SchemaWalkResult, apply_schema_defaults,
apply_schema_defaults_to_node, canonical_json, collect_leaf_paths, collect_schema_leaves,
Expand Down
Loading
Loading