I am implementing a MIP Server to apply labels to pdf files. I have created a setLabel function that gets the label
from the portal and applies it to the file. The following code snippet explains my implementation.
MayBeValue<void*> MipProfile::SetLabel(const CommonParams& p,
const std::string& sourcePath,
const std::string& destPath,
const std::string& labelId,
bool isDryRun,
const LabelOptions& options) {
try {
auto engineId = getEngineId(p.ctx, p.tenantId, p.clientId, p.accountId, "");
if (engineId.getStatus() != STATUS_SUCCESS) {
return MayBeValue<void*>(STATUS_FAILED, "failed to get/create file engine");
}
auto authDelegateImpl = make_shared<AuthDelegateImpl>(p.clientId);
authDelegateImpl->SetTenant(p.tenantId);
authDelegateImpl->SetAccount(p.accountId);
LOG_INFO(p.ctx, "engine uuid : ", engineId.getValue());
FileEngine::Settings engineSettings(
engineId.getValue(), // pass engine Id if its available
authDelegateImpl, // auth token provider class
"<engine-state>", // User-defined engine state, not used
"en-US");
// Set up promise/future connection for async engine operations; add engine
// to profile asynchronously
auto enginePromise = make_shared<promise<shared_ptr<FileEngine>>>();
auto engineFuture = enginePromise->get_future();
// will load or add the engine
mProfile->AddEngineAsync(engineSettings, enginePromise);
// get the engine object and query labels
auto engine = engineFuture.get();
auto newLabel = engine->GetLabelById(labelId);
If I start the server and try to apply the label from the list of labels in the Microsoft Purview portal, it works as expected (the label is being applied to the file).
The problem occurs when I create a new label, add it to the policy and then try to add that label to the file, I get the following error.
{"level" : "ERROR", "caller" : "cmake/build/CMakeFiles/main.dir/compiler_depend.ts:328", "msg" : "An exception occurred... while labeling file : label ID was not found in the policy: 290c79ef-5dff-4617-8281-232e425cc557, BadInputError.Code=General, CorrelationId=4a7be23d-53a1-4e28-a775-093154b74d6c, CorrelationId.Description=PolicyEngine"
I have set the cache type as mip::CacheStorageType::InMemory
as its a long-running process. I need to figure out how can I fetch the latest labels in the already-running policy engine. I am using MIP SDK version 1.12.101 macOS M1.