hcengineering/platform · error · Error
attribute not found
Error message
attribute not found
What it means
ValueSelector.svelte's changeValue looks up the attribute being edited on the document's class (or the castRequest mixin) via hierarchy.getAttribute before calling updateAttribute. If the hierarchy has no attribute with that key for the resolved class/mixin, it throws Error('attribute not found'). This is a client-side programming/configuration error: the component was rendered with an `attribute` prop that does not exist on the objects it is bound to.
Source
Thrown at plugins/view-resources/src/components/ValueSelector.svelte:64
return
}
progress = true
const docs = [...(Array.isArray(value) ? value : [value])]
const changed = (d: Doc) => (d as any)[attribute] !== newStatus
const ops = client.apply('value-selector:' + generateId())
// We need to sort docs by modified date, to have same modified order impacted.
docs.sort((a: Doc, b: Doc) => b._id.localeCompare(a._id))
for (const it of docs.filter(changed)) {
const cl = Hierarchy.mixinOrClass(it)
const attr =
castRequest !== undefined
? hierarchy.getAttribute(castRequest, attribute)
: hierarchy.getAttribute(cl, attribute)
if (attr === undefined) {
throw new Error('attribute not found')
}
await updateAttribute(ops, it, cl, { key: attribute, attr }, newStatus)
}
await ops.commit()
progress = false
dispatch('close', newStatus)
}
$: current = Array.isArray(value)
? value.every((v) => (v as any)[attribute] === (value as any[])[0][attribute])
? (value as any[])[0][attribute]
: value
: (value as any)[attribute]
let finalQuery: DocumentQuery<Doc> = {}
let docMatch = true
View on GitHub (pinned to 63e28dc964)
Solutions
- Check the `attribute` prop spelling against the actual class/mixin model definition for the bound documents.
- If the attribute belongs to a mixin, pass castRequest=<Ref<Mixin>> so getAttribute resolves it against the mixin instead of the base class.
- Ensure all docs in a multi-selection share the class/mixin that defines the attribute (filter the selection or disable the control otherwise).
- Verify the domain plugin defining the class is installed/upgraded so the hierarchy contains the attribute.
- Guard before use: call hierarchy.getAttribute yourself and show a disabled state instead of letting changeValue throw.
Example fix
// before
const attr = castRequest !== undefined
? hierarchy.getAttribute(castRequest, attribute)
: hierarchy.getAttribute(cl, attribute)
if (attr === undefined) {
throw new Error('attribute not found')
}
// after
const attr = castRequest !== undefined
? hierarchy.getAttribute(castRequest, attribute)
: hierarchy.getAttribute(cl, attribute)
if (attr === undefined) {
console.error(`ValueSelector: attribute '${attribute}' not found on ${cl}`, it)
dispatch('close', undefined)
return
} Defensive patterns
Strategy: validation
Validate before calling
const hierarchy = getClient().getHierarchy()
const cl = Hierarchy.mixinOrClass(value)
const attr = castRequest !== undefined
? hierarchy.getAttribute(castRequest, attribute)
: hierarchy.getAttribute(cl, attribute)
if (attr === undefined) {
// render control as disabled instead of attempting the update
} Type guard
function hasAttribute (hierarchy: Hierarchy, cl: Ref<Class<Doc>>, attribute: string, castRequest?: Ref<Mixin<Doc>>): boolean {
return (castRequest !== undefined
? hierarchy.getAttribute(castRequest, attribute)
: hierarchy.getAttribute(cl, attribute)) !== undefined
} Try / catch
try {
await changeValue(newValue)
} catch (err) {
if (err.message === 'attribute not found') {
console.error(`Attribute '${attribute}' missing on object class`, err)
dispatch('close', undefined)
} else {
throw err
}
} Prevention
- Pass castRequest whenever the attribute is defined on a mixin, not the base class.
- Validate the attribute prop against the hierarchy at component init and disable the selector if absent.
- For multi-selection, ensure all selected docs share the same class/mixin defining the attribute.
- Update all ValueSelector call sites when renaming model attributes.
When it happens
Trigger: Rendering ValueSelector with an `attribute` key not defined on the value's class (e.g. typo in the attribute name, attribute only exists on a mixin but castRequest is undefined, or the doc is a subclass lacking the parent's attribute). The lookup happens per doc inside docs.filter(changed), so it fires on the first mismatching doc during a value change.
Common situations: Passing a mixin attribute key without setting castRequest to that mixin; mixed selection where Array<Doc> contains docs of different classes and one lacks the attribute; renaming an attribute in the model without updating component call sites; plugin version mismatch between view-resources and the domain plugin defining the class.
Related errors
- Mixin ${questions.mixin.QuestionMixin} not found for questio
- ancestors not found: ${_class}
- class not found: ${_class}
- interface not found: ${_interface}
- domain not found: ${_class}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/4d33e14da490551e.
Report an issue: GitHub.