mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
pretty print contract IDs properly (#11359)
CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
bb4f4c5a40
commit
3098b70624
@ -153,7 +153,7 @@ object Error {
|
||||
final case class DamlException(error: interpretation.Error) extends Error {
|
||||
override def message: String = error match {
|
||||
case interpretation.Error.ContractNotFound(cid) =>
|
||||
s"Contract could not be found with id $cid"
|
||||
s"Contract could not be found with id ${cid.coid}"
|
||||
case interpretation.Error.ContractKeyNotFound(key) =>
|
||||
s"dependency error: couldn't find key: $key"
|
||||
case _ =>
|
||||
|
@ -97,11 +97,11 @@ private[lf] object Pretty {
|
||||
case NonComparableValues =>
|
||||
text("functions are not comparable")
|
||||
case ContractIdComparability(globalCid) =>
|
||||
text(s"The global contract ID $globalCid conflicts with a local contract ID")
|
||||
text(s"The global contract ID") & prettyContractId(globalCid) &
|
||||
text("conflicts with a local contract ID")
|
||||
case ContractIdInContractKey(key) =>
|
||||
text(
|
||||
s"Contract IDs are not supported in contract keys: ${key.ensureNoCid.left.toOption.get}"
|
||||
)
|
||||
text("Contract IDs are not supported in contract keys:") &
|
||||
prettyContractId(key.ensureNoCid.left.toOption.get)
|
||||
case ValueExceedsMaxNesting =>
|
||||
text(s"Value exceeds maximum nesting value of 100")
|
||||
}
|
||||
|
@ -975,7 +975,10 @@ private[lf] object SBuiltin {
|
||||
val chosenValue = onLedger.ptx.normValue(templateId, args.get(0))
|
||||
val coid = getSContractId(args, 1)
|
||||
val cached =
|
||||
onLedger.cachedContracts.getOrElse(coid, crash(s"Contract $coid is missing from cache"))
|
||||
onLedger.cachedContracts.getOrElse(
|
||||
coid,
|
||||
crash(s"Contract ${coid.coid} is missing from cache"),
|
||||
)
|
||||
val sigs = cached.signatories
|
||||
val templateObservers = cached.observers
|
||||
val ctrls = extractParties(NameOf.qualifiedNameOfCurrentFunc, args.get(2))
|
||||
@ -1024,7 +1027,7 @@ private[lf] object SBuiltin {
|
||||
if (cached.templateId != templateId) {
|
||||
if (onLedger.ptx.localContracts.contains(coid)) {
|
||||
// This should be prevented by the type checker so it’s an internal error.
|
||||
crash(s"contract $coid ($templateId) not found from partial transaction")
|
||||
crash(s"contract ${coid.coid} ($templateId) not found from partial transaction")
|
||||
} else {
|
||||
// This is a user-error.
|
||||
machine.ctrl = SEDamlException(
|
||||
@ -1192,7 +1195,10 @@ private[lf] object SBuiltin {
|
||||
): Unit = {
|
||||
val coid = getSContractId(args, 0)
|
||||
val cached =
|
||||
onLedger.cachedContracts.getOrElse(coid, crash(s"Contract $coid is missing from cache"))
|
||||
onLedger.cachedContracts.getOrElse(
|
||||
coid,
|
||||
crash(s"Contract ${coid.coid} is missing from cache"),
|
||||
)
|
||||
val signatories = cached.signatories
|
||||
val observers = cached.observers
|
||||
val key = cached.key
|
||||
@ -1335,7 +1341,7 @@ private[lf] object SBuiltin {
|
||||
case Some(PartialTransaction.KeyActive(coid))
|
||||
if onLedger.ptx.localContracts.contains(coid) =>
|
||||
val cachedContract = onLedger.cachedContracts
|
||||
.getOrElse(coid, crash(s"Local contract $coid not in cachedContracts"))
|
||||
.getOrElse(coid, crash(s"Local contract ${coid.coid} not in cachedContracts"))
|
||||
val stakeholders = cachedContract.signatories union cachedContract.observers
|
||||
onLedger.visibleToStakeholders(stakeholders) match {
|
||||
case SVisibleToStakeholders.Visible =>
|
||||
|
@ -261,7 +261,7 @@ object ScenarioRunner {
|
||||
case ScenarioLedger.LookupContractNotFound(coid) =>
|
||||
// This should never happen, hence we don't have a specific
|
||||
// error for this.
|
||||
throw Error.Internal(s"contract $coid not found")
|
||||
throw Error.Internal(s"contract ${coid.coid} not found")
|
||||
|
||||
case ScenarioLedger.LookupContractNotEffective(coid, tid, effectiveAt) =>
|
||||
throw Error.ContractNotEffective(coid, tid, effectiveAt)
|
||||
|
@ -1 +1 @@
|
||||
Error: Contract IDs are not supported in contract keys: ContractId(00fa6dbc32b678ec8a97ed0de226e397a4e2d521097b879d0146979556e7cd3e58)
|
||||
Error: Contract IDs are not supported in contract keys: 00fa6dbc32b678ec8a97ed0de226e397a4e2d521097b879d0146979556e7cd3e58
|
||||
|
@ -1141,7 +1141,7 @@ abstract class AbstractHttpServiceIntegrationTest
|
||||
status shouldBe StatusCodes.Conflict
|
||||
assertStatus(output, StatusCodes.Conflict)
|
||||
expectedOneErrorMessage(output) should include(
|
||||
s"Contract could not be found with id ContractId($contractIdString)"
|
||||
s"Contract could not be found with id $contractIdString"
|
||||
)
|
||||
}: Future[Assertion]
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ final class ContractIdIT extends LedgerTestSuite {
|
||||
// Assert V1 error code
|
||||
case Failure(GrpcException(GrpcStatus(Status.Code.ABORTED, Some(msg)), _))
|
||||
if !alpha.features.selfServiceErrorCodes && msg.contains(
|
||||
s"Contract could not be found with id ContractId($testedCid)"
|
||||
s"Contract could not be found with id $testedCid"
|
||||
) =>
|
||||
Success(())
|
||||
|
||||
|
@ -111,7 +111,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]](
|
||||
if (otherContractLet.isAfter(let)) {
|
||||
Some(
|
||||
InvalidLedgerTime(
|
||||
s"Encountered contract [$cid] with LET [$otherContractLet] greater than the LET of the transaction [$let]"
|
||||
s"Encountered contract [${cid.coid}] with LET [$otherContractLet] greater than the LET of the transaction [$let]"
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@ -125,7 +125,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]](
|
||||
None
|
||||
case None =>
|
||||
// Contract not known
|
||||
Some(Inconsistent(s"Could not lookup contract $cid"))
|
||||
Some(Inconsistent(s"Could not lookup contract ${cid.coid}"))
|
||||
}
|
||||
|
||||
def handleLeaf(
|
||||
@ -160,7 +160,7 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]](
|
||||
// A contract starts its life without being divulged at all.
|
||||
divulgences = Map.empty,
|
||||
key = nc.versionedKey.map(
|
||||
_.assertNoCid(coid => s"Contract ID $coid found in contract key")
|
||||
_.assertNoCid(coid => s"Contract ID ${coid.coid} found in contract key")
|
||||
),
|
||||
signatories = nc.signatories,
|
||||
observers = nc.stakeholders.diff(nc.signatories),
|
||||
@ -196,7 +196,10 @@ private[platform] class ActiveLedgerStateManager[ALS <: ActiveLedgerState[ALS]](
|
||||
case nlkup: N.NodeLookupByKey =>
|
||||
// Check that the stored lookup result matches the current result
|
||||
val key = nlkup.key.key.ensureNoCid.fold(
|
||||
coid => throw new IllegalStateException(s"Contract ID $coid found in contract key"),
|
||||
coid =>
|
||||
throw new IllegalStateException(
|
||||
s"Contract ID ${coid.coid} found in contract key"
|
||||
),
|
||||
identity,
|
||||
)
|
||||
val gk = GlobalKey(nlkup.templateId, key)
|
||||
|
@ -77,8 +77,9 @@ private[events] object TransactionLogUpdatesConversions {
|
||||
contractIds + event.contractId
|
||||
case (contractIds, event: ExercisedEvent) if event.consuming =>
|
||||
contractIds - event.contractId
|
||||
case (contractId, _) =>
|
||||
throw new RuntimeException(s"Unexpected non-consuming event for contractId $contractId")
|
||||
case (contractIds, _) =>
|
||||
val prettyCids = contractIds.iterator.map(_.coid).mkString(", ")
|
||||
throw new RuntimeException(s"Unexpected non-consuming event for contractIds $prettyCids")
|
||||
}
|
||||
aux.filter(ev => permanent(ev.contractId))
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ private[platform] class MutableCacheBackedContractStore(
|
||||
// (the contract might have been divulged to the readers)
|
||||
// OR the contract was not found in the index
|
||||
//
|
||||
logger.debug(s"Checking divulgence for contractId=$contractId and readers=$readers")
|
||||
logger.debug(s"Checking divulgence for contractId=${contractId.coid} and readers=$readers")
|
||||
resolveDivulgenceLookup(contractStateValue, contractId, readers)
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ private[platform] class MutableCacheBackedContractStore(
|
||||
eventSequentialId,
|
||||
) =>
|
||||
logger.debug(
|
||||
s"State events update: Created(contractId=$contractId, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)"
|
||||
s"State events update: Created(contractId=${contractId.coid}, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)"
|
||||
)
|
||||
case ContractStateEvent.Archived(
|
||||
contractId,
|
||||
@ -291,7 +291,7 @@ private[platform] class MutableCacheBackedContractStore(
|
||||
eventSequentialId,
|
||||
) =>
|
||||
logger.debug(
|
||||
s"State events update: Archived(contractId=$contractId, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)"
|
||||
s"State events update: Archived(contractId=${contractId.coid}, globalKey=$globalKey, offset=$eventOffset, eventSequentialId=$eventSequentialId)"
|
||||
)
|
||||
case LedgerEndMarker(eventOffset, eventSequentialId) =>
|
||||
logger.debug(
|
||||
@ -390,7 +390,7 @@ private[platform] object MutableCacheBackedContractStore {
|
||||
|
||||
final case class ContractReadThroughNotFound(contractId: ContractId) extends NoStackTrace {
|
||||
override def getMessage: String =
|
||||
s"Contract not found for contract id $contractId. Hint: this could be due racing with a concurrent archival."
|
||||
s"Contract not found for contract id ${contractId.coid}. Hint: this could be due racing with a concurrent archival."
|
||||
}
|
||||
|
||||
private[cache] class CacheIndex(initValue: (Offset, Long)) {
|
||||
|
Loading…
Reference in New Issue
Block a user