fix(import): align external URI identity with HTTP transport
CI / Rust Checks (pull_request) Successful in 25m55s
CI / UI Checks (pull_request) Successful in 5s
CI / Community Image Smoke (pull_request) Successful in 7m42s
CI / Frontend E2E (pull_request) Successful in 12m39s
CI / Deploy (pull_request) Skipped

Share pure URL canonicalization between snapshot materialization and resolution. Preserve historical v5/v6 previews while advancing normalization to v6 and the support matrix to 1.0.4. Cover encoded-dot paths, apostrophe queries, relative children, and no-refetch apply/replay.
This commit is contained in:
bsodfather committed 2026-10-11 08:33:43 +03:00
1 parent 178093e81b
commit 9e9c326c3e
22 files changed
+1669 -353

No files matched your search

+3 -21
View File
@@ -7,8 +7,8 @@ use crank_core::{
};
use crank_import::rest::{
ImportFinding, ImportFindingSeverity, ImportNameConflict, ImportOperationCandidate,
NORMALIZER_VERSION, PROJECTION_VERSION, operation_draft_from_candidate,
validate_document_source_safe,
NORMALIZER_VERSION, PROJECTION_VERSION, canonical_external_document_uri,
operation_draft_from_candidate, validate_document_source_safe,
};
use crank_registry::{
ApplyImportJobRequest, ArtifactSourceId, ArtifactSourceSensitivity,
@@ -55,7 +55,7 @@ const IMPORT_JOB_TTL_HOURS: i64 = 24;
const OPENAPI_PARSE_DEADLINE: std::time::Duration = std::time::Duration::from_secs(30);
const OPENAPI_PARSE_CONCURRENCY: usize = 4;
const MAX_IMPORT_PLAN_KEYS: usize = 2_000;
const OPENAPI_SUPPORT_MATRIX_VERSION: &str = "1.0.3";
const OPENAPI_SUPPORT_MATRIX_VERSION: &str = "1.0.4";
const MAX_IMPORT_PLAN_KEY_BYTES: usize = 4_096;
const MAX_IMPORT_PLAN_SERVER_URL_BYTES: usize = 8_192;
const MAX_IMPORT_PLAN_NAME_BYTES: usize = 256;
@@ -664,24 +664,6 @@ impl AdminService {
}
}
fn canonical_external_document_uri(base: Option<&str>, reference: &str) -> Option<String> {
if reference.starts_with('#') {
return None;
}
let mut url = match base {
Some(base) => url::Url::parse(base).ok()?.join(reference).ok()?,
None => url::Url::parse(reference).ok()?,
};
if !matches!(url.scheme(), "http" | "https")
|| !url.username().is_empty()
|| url.password().is_some()
{
return None;
}
url.set_fragment(None);
Some(url.to_string())
}
fn openapi_import_response(applied: ImportJobApplyResult) -> OpenApiImportCreateResponse {
let created = applied
.created
@@ -210,6 +210,10 @@ fn import_replay_contract(
| ("normalized-ir-v3", "preview-v3")
| ("normalized-ir-v4", "preview-v4")
| ("normalized-ir-v5", "preview-v5")
// The v5/preview-v6 pair predates the shared external-URI identity
// (normalized-ir-v6). Its saved projection is authoritative and is
// replayed verbatim, never reparsed under the current normalizer.
| ("normalized-ir-v5", "preview-v6")
) {
return Err(ApiError::openapi_upload(locale, "source_integrity"));
}