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
16 changes: 14 additions & 2 deletions packages/objectql/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,29 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
}

async getMetaItems(request: { type: string; packageId?: string }) {
let items = SchemaRegistry.listItems(request.type, request.packageId);
// Normalize singular/plural: REST uses singular ('app') but registry may store as plural ('apps')
if (items.length === 0) {
const alt = request.type.endsWith('s') ? request.type.slice(0, -1) : request.type + 's';
items = SchemaRegistry.listItems(alt, request.packageId);
}
Comment on lines 61 to +67
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The singular/plural fallback for type is too naive: endsWith('s') ? slice(0, -1) : + 's' will generate incorrect alternates for many valid registry keys (e.g. policies -> policie, analytics -> analytic) and may mask real “type not found” errors. Consider restricting this normalization to known pairs (e.g. app<->apps) or using an explicit alias map rather than heuristic string slicing.

Copilot uses AI. Check for mistakes.
return {
type: request.type,
items: SchemaRegistry.listItems(request.type, request.packageId)
items
};
}

async getMetaItem(request: { type: string, name: string }) {
let item = SchemaRegistry.getItem(request.type, request.name);
// Normalize singular/plural
if (item === undefined) {
const alt = request.type.endsWith('s') ? request.type.slice(0, -1) : request.type + 's';
item = SchemaRegistry.getItem(alt, request.name);
}
Comment on lines 74 to +80
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above in getMetaItem: the heuristic singular/plural fallback can produce invalid type names and hide actual lookup failures. Prefer a small explicit alias map (or only special-case app/apps) so registry lookups remain predictable.

Copilot uses AI. Check for mistakes.
return {
type: request.type,
name: request.name,
item: SchemaRegistry.getItem(request.type, request.name)
item
};
}

Expand Down
Loading
Loading