Compare commits

...

2 Commits

Author SHA1 Message Date
bfe3dd2e8c version: 1.0.115 2026-04-14 09:36:12 -04:00
609371c03c fixed drop errors for database initialization 2026-04-14 09:36:04 -04:00
10 changed files with 50 additions and 30 deletions

View File

@ -60,10 +60,14 @@ impl Database {
db.enums.insert(def.name.clone(), def);
}
Err(e) => {
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
errors.push(crate::drop::Error {
code: "DATABASE_ENUM_PARSE_FAILED".to_string(),
message: format!("Failed to parse database enum: {}", e),
details: crate::drop::ErrorDetails::default(),
message: format!("Failed to parse database enum '{}': {}", name, e),
details: crate::drop::ErrorDetails {
context: Some(serde_json::json!(name)),
..Default::default()
},
});
}
}
@ -77,10 +81,14 @@ impl Database {
db.types.insert(def.name.clone(), def);
}
Err(e) => {
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
errors.push(crate::drop::Error {
code: "DATABASE_TYPE_PARSE_FAILED".to_string(),
message: format!("Failed to parse database type: {}", e),
details: crate::drop::ErrorDetails::default(),
message: format!("Failed to parse database type '{}': {}", name, e),
details: crate::drop::ErrorDetails {
context: Some(serde_json::json!(name)),
..Default::default()
},
});
}
}
@ -98,10 +106,14 @@ impl Database {
}
}
Err(e) => {
let constraint = item.get("constraint").and_then(|v| v.as_str()).unwrap_or("unknown");
errors.push(crate::drop::Error {
code: "DATABASE_RELATION_PARSE_FAILED".to_string(),
message: format!("Failed to parse database relation: {}", e),
details: crate::drop::ErrorDetails::default(),
message: format!("Failed to parse database relation '{}': {}", constraint, e),
details: crate::drop::ErrorDetails {
context: Some(serde_json::json!(constraint)),
..Default::default()
},
});
}
}
@ -115,10 +127,14 @@ impl Database {
db.puncs.insert(def.name.clone(), def);
}
Err(e) => {
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
errors.push(crate::drop::Error {
code: "DATABASE_PUNC_PARSE_FAILED".to_string(),
message: format!("Failed to parse database punc: {}", e),
details: crate::drop::ErrorDetails::default(),
message: format!("Failed to parse database punc '{}': {}", name, e),
details: crate::drop::ErrorDetails {
context: Some(serde_json::json!(name)),
..Default::default()
},
});
}
}
@ -135,7 +151,10 @@ impl Database {
errors.push(crate::drop::Error {
code: "DATABASE_SCHEMA_PARSE_FAILED".to_string(),
message: format!("Failed to parse database schema key '{}': {}", key, e),
details: crate::drop::ErrorDetails::default(),
details: crate::drop::ErrorDetails {
context: Some(serde_json::json!(key)),
..Default::default()
},
});
}
}
@ -282,7 +301,7 @@ impl Database {
// Abort relation discovery early if no hierarchical inheritance match was found
if matching_rels.is_empty() {
let mut details = crate::drop::ErrorDetails {
path: path.to_string(),
path: Some(path.to_string()),
..Default::default()
};
if let Some(sid) = schema_id {
@ -381,7 +400,7 @@ impl Database {
// and forces a clean structural error for the architect.
if !resolved {
let mut details = crate::drop::ErrorDetails {
path: path.to_string(),
path: Some(path.to_string()),
context: serde_json::to_value(&matching_rels).ok(),
cause: Some("Multiple conflicting constraints found matching prefixes".to_string()),
..Default::default()

View File

@ -103,7 +103,7 @@ impl Schema {
types
),
details: crate::drop::ErrorDetails {
path: path.clone(),
path: Some(path.clone()),
schema: Some(root_id.to_string()),
..Default::default()
}
@ -427,7 +427,7 @@ impl Schema {
code: "AMBIGUOUS_POLYMORPHISM".to_string(),
message: format!("oneOf boundaries must map mathematically unique 'type' or 'kind' discriminators, or strictly contain disjoint primitive types."),
details: crate::drop::ErrorDetails {
path: path.to_string(),
path: Some(path.to_string()),
schema: Some(root_id.to_string()),
..Default::default()
}
@ -449,7 +449,7 @@ impl Schema {
code: "POLYMORPHIC_COLLISION".to_string(),
message: format!("Polymorphic boundary defines multiple candidates mapped to the identical discriminator value '{}'.", val),
details: crate::drop::ErrorDetails {
path: path.to_string(),
path: Some(path.to_string()),
schema: Some(root_id.to_string()),
..Default::default()
}
@ -491,7 +491,7 @@ impl Schema {
c, field_name, id
),
details: crate::drop::ErrorDetails {
path: path.to_string(),
path: Some(path.to_string()),
schema: Some(root_id.to_string()),
..Default::default()
},

View File

@ -66,7 +66,8 @@ pub struct Error {
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ErrorDetails {
pub path: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub path: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cause: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]

View File

@ -30,7 +30,7 @@ fn jspg_failure() -> JsonB {
code: "ENGINE_NOT_INITIALIZED".to_string(),
message: "JSPG extension has not been initialized via jspg_setup".to_string(),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: None,
context: None,
schema: None,

View File

@ -31,7 +31,7 @@ impl Merger {
code: "MERGE_FAILED".to_string(),
message: format!("Unknown schema_id: {}", schema_id),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: None,
context: Some(data),
schema: None,
@ -76,7 +76,7 @@ impl Merger {
code: final_code,
message: final_message,
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: final_cause,
context: None,
schema: None,
@ -92,7 +92,7 @@ impl Merger {
code: "MERGE_FAILED".to_string(),
message: format!("Executor Error in pre-ordered notify: {:?}", e),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: None,
context: None,
schema: None,

View File

@ -33,7 +33,7 @@ impl Queryer {
code: "FILTER_PARSE_FAILED".to_string(),
message: msg.clone(),
details: crate::drop::ErrorDetails {
path: "".to_string(), // filters apply to the root query
path: None, // filters apply to the root query
cause: Some(msg),
context: filters.cloned(),
schema: Some(schema_id.to_string()),
@ -138,7 +138,7 @@ impl Queryer {
code: "QUERY_COMPILATION_FAILED".to_string(),
message: e.clone(),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: Some(e),
context: None,
schema: Some(schema_id.to_string()),
@ -165,7 +165,7 @@ impl Queryer {
code: "QUERY_FAILED".to_string(),
message: format!("Expected array from generic query, got: {:?}", other),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: Some(format!("Expected array, got {}", other)),
context: Some(serde_json::json!([sql])),
schema: Some(schema_id.to_string()),
@ -175,7 +175,7 @@ impl Queryer {
code: "QUERY_FAILED".to_string(),
message: format!("SPI error in queryer: {}", e),
details: crate::drop::ErrorDetails {
path: "".to_string(),
path: None,
cause: Some(format!("SPI error in queryer: {}", e)),
context: Some(serde_json::json!([sql])),
schema: Some(schema_id.to_string()),

View File

@ -18,7 +18,7 @@ fn test_library_api() {
"errors": [{
"code": "ENGINE_NOT_INITIALIZED",
"message": "JSPG extension has not been initialized via jspg_setup",
"details": { "path": "" }
"details": {}
}]
})
);

View File

@ -86,7 +86,7 @@ pub fn run_test_case(path: &str, suite_idx: usize, case_idx: usize) -> Result<()
let error_messages: Vec<String> = drop
.errors
.iter()
.map(|e| format!("Error {} at path {}: {}", e.code, e.details.path, e.message))
.map(|e| format!("Error {} at path {}: {}", e.code, e.details.path.as_deref().unwrap_or("/"), e.message))
.collect();
failures.push(format!(
"[{}] Cannot run '{}' test '{}': System Setup Compilation structurally failed:\n{}",

View File

@ -68,7 +68,7 @@ impl Validator {
code: e.code,
message: e.message,
details: crate::drop::ErrorDetails {
path: e.path,
path: Some(e.path),
cause: None,
context: None,
schema: None,
@ -82,7 +82,7 @@ impl Validator {
code: e.code,
message: e.message,
details: crate::drop::ErrorDetails {
path: e.path,
path: Some(e.path),
cause: None,
context: None,
schema: None,
@ -94,7 +94,7 @@ impl Validator {
code: "SCHEMA_NOT_FOUND".to_string(),
message: format!("Schema {} not found", schema_id),
details: crate::drop::ErrorDetails {
path: "/".to_string(),
path: Some("/".to_string()),
cause: None,
context: None,
schema: None,

View File

@ -1 +1 @@
1.0.114
1.0.115