Skip to content

Commit 5929a13

Browse files
committed
feat: add piece status to indicate invalid package container source SOFIE-2991
1 parent 275c34a commit 5929a13

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

meteor/server/publications/packageManager/expectedPackages/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ function generateExpectedPackageForDevice(
194194
if (lookedUpSource) {
195195
combinedSources.push(calculateCombinedSource(packageSource, lookedUpSource))
196196
} else {
197-
logger.warn(
198-
`Pub.expectedPackagesForDevice: Source package container "${packageSource.containerId}" not found`
199-
)
197+
// This can happen if the blueprints reference a Package Container that is for another studio.
198+
// checkPieceContentStatus will formulate a proper status for this situation
199+
200200
// Add a placeholder source, it's used to provide users with a hint of what's wrong
201201
combinedSources.push({
202202
containerId: packageSource.containerId,

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,26 @@ async function checkPieceContentExpectedPackageStatus(
633633
expectedPackageIds.unshift(getExpectedPackageId(piece.pieceInstanceId, expectedPackage._id))
634634
}
635635

636+
const fileName = getExpectedPackageFileName(expectedPackage) ?? ''
637+
638+
// Check if any of the sources exist and are valid
639+
// Future: This might be better to do by passing packageManager an 'forcedError' property in the publication, but this direct check is simpler and enough for now
640+
const hasValidSources =
641+
expectedPackage.sources &&
642+
(expectedPackage.sources.length === 0 ||
643+
!expectedPackage.sources.find((source) => !studio.packageContainers[source.containerId]))
644+
if (!hasValidSources) {
645+
// The expected package has no valid sources
646+
647+
pushOrMergeMessage({
648+
status: PieceStatusCode.SOURCE_MISSING,
649+
message: PackageStatusMessage.FILE_MISSING_SOURCE_CONTAINERS,
650+
fileName: fileName,
651+
packageContainers: expectedPackage.sources.map((s) => s.containerId), // Ideally this would be labels, but the containers are missing
652+
})
653+
continue
654+
}
655+
636656
let warningMessage: ContentMessageLight | null = null
637657
let matchedExpectedPackageId: ExpectedPackageId | null = null
638658
for (const expectedPackageId of expectedPackageIds) {
@@ -676,7 +696,6 @@ async function checkPieceContentExpectedPackageStatus(
676696
break
677697
}
678698

679-
const fileName = getExpectedPackageFileName(expectedPackage) ?? ''
680699
const containerLabel = matchedPackageContainer[1].container.label
681700

682701
if (!matchedExpectedPackageId || warningMessage) {

meteor/server/publications/pieceContentStatusUI/messageFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const DEFAULT_MESSAGES: Record<PackageStatusMessage, ITranslatableMessage> = {
1616
[PackageStatusMessage.FILE_IS_MISSING]: generateTranslation('{{sourceLayer}} is missing'),
1717

1818
// Package manager
19+
[PackageStatusMessage.FILE_MISSING_SOURCE_CONTAINERS]: generateTranslation(
20+
'{{sourceLayer}} has unsupported source: {{containerLabels}}'
21+
),
1922
[PackageStatusMessage.FILE_CANT_BE_FOUND_ON_PLAYOUT_SYSTEM]: generateTranslation(
2023
`{{sourceLayer}} can't be found on the playout system`
2124
),

packages/shared-lib/src/packageStatusMessages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export enum PackageStatusMessage {
3333
FILE_IS_MISSING = 'FILE_IS_MISSING',
3434

3535
// Package manager
36+
/**
37+
* The file has no valid source package containers
38+
*/
39+
FILE_MISSING_SOURCE_CONTAINERS = 'FILE_MISSING_SOURCE_CONTAINERS',
3640
/**
3741
* The file can't be found on the playout system
3842
*/

0 commit comments

Comments
 (0)