canopy-network/canopy · error · Error
Could not find types.proto descriptor
Error message
Could not find types.proto descriptor
What it means
The generate-descriptors.cjs build script compiles the proto directory into a consolidated descriptor set via protobufjs, then splits it back into per-file descriptors. It expects the compiled set to contain a file named exactly 'types.proto' (the name protobufjs consolidates under). If no descriptor file with that name is present in descriptorSet.file, the script throws this error, because the split step cannot proceed without it.
Source
Thrown at plugin/typescript/scripts/generate-descriptors.cjs:86
const enumMatches = content.matchAll(/^enum\s+(\w+)\s*\{/gm);
fileTypes[protoFile] = {
messages: [...messageMatches].map(m => m[1]),
enums: [...enumMatches].map(m => m[1]),
};
}
// Find the consolidated types.proto descriptor
let typesDescriptor = null;
for (const file of descriptorSet.file) {
if (file.name === 'types.proto') {
typesDescriptor = file;
break;
}
}
if (!typesDescriptor) {
throw new Error('Could not find types.proto descriptor');
}
// Create individual file descriptors by cloning and filtering
for (const protoFile of protoFiles) {
const types = fileTypes[protoFile];
// Clone the descriptor and filter to only include types from this file
const fileDesc = {
name: protoFile,
package: typesDescriptor.package,
dependency: [],
messageType: [],
enumType: [],
syntax: typesDescriptor.syntax,
options: typesDescriptor.options,
};
// Add google/protobuf/any.proto dependency if neededView on GitHub (pinned to ee8197d91d)
Solutions
- Re-run the full proto pipeline in order: `npm run build:proto` then `npm run build:descriptors` (or `make build-all`), so the descriptor set is regenerated fresh and contains the consolidated types.proto.
- Verify the descriptor-compilation step in generate-descriptors.cjs actually loads all proto files from proto/ and check the descriptorSet.file names it produces (log them) to confirm whether 'types.proto' is missing or renamed.
- If you renamed/moved types.proto in the proto directory, restore it or update the `file.name === 'types.proto'` lookup in the script to match the new name.
- Clean stale build artifacts (generated index.js, descriptors output, intermediate descriptor set) and rebuild from a clean checkout.
Example fix
// before (script looks only for types.proto)
for (const file of descriptorSet.file) {
if (file.name === 'types.proto') { typesDescriptor = file; break; }
}
// after (log available names to diagnose, fall back to first descriptor)
console.log('descriptor files:', descriptorSet.file.map(f => f.name));
for (const file of descriptorSet.file) {
if (file.name === 'types.proto') { typesDescriptor = file; break; }
} Defensive patterns
Strategy: validation
Validate before calling
const names = descriptorSet.file.map(f => f.name);
if (!names.includes('types.proto')) {
throw new Error(`types.proto missing from descriptor set; got: ${names.join(', ')}`);
} Type guard
function hasTypesDescriptor(set) {
return Array.isArray(set?.file) && set.file.some(f => f?.name === 'types.proto');
} Try / catch
try {
buildDescriptors(descriptorSet);
} catch (err) {
if (err.message.includes('Could not find types.proto')) {
console.error('Descriptor set malformed; re-run `npm run build:proto` first.', err.message);
process.exit(1);
}
throw err;
} Prevention
- Always run build:proto before build:descriptors (use make build-all).
- Log descriptorSet.file names once in CI to catch renames early.
- Never hand-edit the proto directory names that the script depends on.
- Clean intermediate build artifacts when switching branches or protobufjs versions.
When it happens
Trigger: Running `npm run build:descriptors` (or `make build-descriptors`) after the proto compilation step produced a descriptor set without a 'types.proto' entry — e.g. the pbjs/proto loader output was generated differently, the proto dir contents changed, or a stale/partial descriptor-set file is passed in.
Common situations: Re-running the descriptor build with a custom proto directory that renames types.proto; regenerating descriptors after editing the script's compilation step; using a different protobufjs version whose output file naming differs; a corrupted or outdated intermediate descriptor file left from a previous build.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Message does not support serialization
- Message type does not support deserialization
- invalid tag at offset %d
- invalid length at offset %d
- field value exceeds buffer bounds
AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06).
Data as JSON: /api/errors/ff5a03e8855e7898.
Report an issue: GitHub.