Skip to content

Commit 5e83c84

Browse files
edrioukCopilot
andauthored
RPC: Tolerate non-critical errors when loading solution (#2404)
For RPC case we can tolerate loading solution with errors like typos in access sequences, missing packs and schema violations. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 18b0ef8 commit 5e83c84

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,23 @@ RpcArgs::SuccessResult RpcHandler::LoadSolution(const string& solution, const st
291291
result.message = solution + " is not a *.csolution.yml file";
292292
return result;
293293
}
294-
result.success = m_solutionLoaded = m_manager.LoadSolution(csolutionFile, activeTarget);
295-
if(!m_solutionLoaded) {
294+
// we disregard return value of m_manager.LoadSolution() here, because we tolerate some errors
295+
m_manager.LoadSolution(csolutionFile, activeTarget);
296+
map<string, ContextItem>* contexts = nullptr;
297+
m_worker.GetContexts(contexts);
298+
bool hasUsableContext = false;
299+
if (contexts && !contexts->empty()) {
300+
// ensure at least one context has a valid active target
301+
for (const auto& contextItem : *contexts) {
302+
if (contextItem.second.rteActiveTarget != nullptr) {
303+
hasUsableContext = true;
304+
break;
305+
}
306+
}
307+
}
308+
result.success = m_solutionLoaded = hasUsableContext;
309+
if(!result.success) {
310+
// severe situation: contexts were not populated or are unusable
296311
result.message = "failed to load and process solution " + csolutionFile;
297312
}
298313
return result;

0 commit comments

Comments
 (0)