Skip to content

Commit f19aec9

Browse files
sugyanclaude
andcommitted
fix(codegen): Generate Collection impls for camelCase record NSIDs
`generate_modules` rebuilt the NSID from the snake_case'd file stem, so a record whose NSID leaf is camelCase never matched its own schema and got no `Collection` impl. Every record so far had a single-word leaf (`profile`, `status`, `listitem`, ...), so this went unnoticed until `app.bsky.actor.contentVisibilityDeclaration`. The mismatch is not cosmetic: `KnownRecord` is built from schema ids and does gain the variant, so downstream crates get a `KnownRecord` arm they cannot satisfy because the `Collection` type does not exist. Match on the snake_case'd NSID leaf instead, and use the schema's own id for the `NSID` constant. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent ff18ee0 commit f19aec9

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

lexicon/atrium-codegen/src/generator.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,17 @@ pub(crate) fn generate_modules(
205205
let collections = names
206206
.iter()
207207
.filter_map(|name| {
208-
let nsid = format!("{}.{}", ns, name);
209208
schemas
210209
.iter()
211210
.find(|schema| {
212-
schema
213-
.defs
214-
.get("main")
215-
.map(|def| {
216-
schema.id == nsid && matches!(def, LexUserType::Record(_))
217-
})
218-
.unwrap_or(false)
211+
// The file stem is the snake_case'd NSID leaf, so match on that
212+
// instead of reconstructing the NSID -- a camelCase leaf such as
213+
// `contentVisibilityDeclaration` would never compare equal.
214+
schema.id.rsplit_once('.').is_some_and(|(prefix, leaf)| {
215+
prefix == ns && leaf.to_snake_case() == *name
216+
}) && matches!(schema.defs.get("main"), Some(LexUserType::Record(_)))
219217
})
220-
.map(|_| collection(name, &nsid))
218+
.map(|schema| collection(name, &schema.id))
221219
})
222220
.collect_vec();
223221
(quote!(#![doc = #doc]), collections)

0 commit comments

Comments
 (0)