|
|
@@ -29,8 +29,37 @@ std::vector<FunctionRecord> FunctionRegistry::list(const std::string& project) {
|
|
|
std::vector<FunctionRecord> out;
|
|
|
smartbotic::database::Client::QueryOptions opts;
|
|
|
opts.limit = 100000;
|
|
|
- for (const auto& doc : db_.client().find(coll(project), opts))
|
|
|
- out.push_back(FunctionRecord::fromJson(doc));
|
|
|
+ try {
|
|
|
+ for (const auto& doc : db_.client().find(coll(project), opts))
|
|
|
+ out.push_back(FunctionRecord::fromJson(doc));
|
|
|
+ } catch (const smartbotic::database::Client::Error& e) {
|
|
|
+ // A PROJECT WITH NO FUNCTIONS HAS NO REGISTRY COLLECTION, AND THAT IS A
|
|
|
+ // NORMAL STATE RATHER THAN A FAILURE.
|
|
|
+ //
|
|
|
+ // The collection is created by the first function PUSH (`ensure` in
|
|
|
+ // `put`), not when the project is created - project-create materialises
|
|
|
+ // the COLLECTION registry, which is a different collection. So every
|
|
|
+ // project that has never had a function pushed made this throw, and the
|
|
|
+ // scheduler and the event watcher each logged a warning for it on EVERY
|
|
|
+ // tick: one line per project per 20 s, 4,320 a day for a single such
|
|
|
+ // project. Found 2026-10-22 by creating one.
|
|
|
+ //
|
|
|
+ // That is worse than untidy. This file is full of warnings about a
|
|
|
+ // failure nothing reports; the mirror is a warning that fires constantly
|
|
|
+ // for a benign condition, because it teaches whoever reads the journal
|
|
|
+ // to skip the line - and the next genuine "could not read registry",
|
|
|
+ // from a transport failure or a registry that really has gone missing
|
|
|
+ // on a project that DOES have functions, arrives looking exactly like
|
|
|
+ // the noise.
|
|
|
+ //
|
|
|
+ // Classified on the CODE, never on the message text, which is the rule
|
|
|
+ // everywhere else here: NotFound means the collection is absent, so the
|
|
|
+ // project has no functions and the empty vector is the honest answer.
|
|
|
+ // Anything else - Unavailable, a permission denial, a malformed row -
|
|
|
+ // still propagates, so a real fault is as loud as it ever was.
|
|
|
+ if (e.code() == smartbotic::database::Client::ErrorCode::NotFound) return out;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
return out;
|
|
|
}
|
|
|
|