diff --git a/plugins/printers/api/asset_routes.py b/plugins/printers/api/asset_routes.py index e626b95e..e2bed15a 100644 --- a/plugins/printers/api/asset_routes.py +++ b/plugins/printers/api/asset_routes.py @@ -1123,12 +1123,18 @@ def set_asset_printer_assignment(asset_id: int): ', '.join(str(assetid) for assetid in sorted(notprinters)))) typeids = _relationship_typeids(_USES_PRINTER, _DEFAULT_PRINTER) - if not typeids[_USES_PRINTER] or not typeids[_DEFAULT_PRINTER]: + missingtypes = [name for name in (_USES_PRINTER, _DEFAULT_PRINTER) + if not typeids[name]] + if missingtypes: # Seed data, not a migration. An un-seeded database cannot hold an - # assignment, and saying so beats writing rows nothing can read. + # assignment, and saying so beats writing rows nothing can read. Name + # the types that are actually missing: a partially seeded table is the + # common case, and "types are not seeded" sends someone looking for an + # empty table they will not find. return error_response( ErrorCodes.INTERNAL_ERROR, - 'Relationship types are not seeded - run: flask seed reference-data', + 'Relationship type(s) not seeded: {0} - run: flask seed ' + 'reference-data'.format(', '.join(missingtypes)), http_code=500) _reconcile_edges(asset_id, typeids[_USES_PRINTER][0], @@ -1784,10 +1790,13 @@ def seed_assignment_from_observed(asset_id: int): details={'hostname': hostname, 'skipped': candidate['skipped']}) typeids = _relationship_typeids(_USES_PRINTER, _DEFAULT_PRINTER, _CONTROLS) - if not typeids[_USES_PRINTER] or not typeids[_DEFAULT_PRINTER]: + missingtypes = [name for name in (_USES_PRINTER, _DEFAULT_PRINTER) + if not typeids[name]] + if missingtypes: return error_response( ErrorCodes.INTERNAL_ERROR, - 'Relationship types are not seeded - run: flask seed reference-data', + 'Relationship type(s) not seeded: {0} - run: flask seed ' + 'reference-data'.format(', '.join(missingtypes)), http_code=500) warnings = []