diff --git a/core/capabilities/compute/compute.go b/core/capabilities/compute/compute.go index 2ba5daefaa6..f27a3e29b0e 100644 --- a/core/capabilities/compute/compute.go +++ b/core/capabilities/compute/compute.go @@ -3,6 +3,7 @@ package compute import ( "context" "crypto/sha256" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -298,9 +299,19 @@ func (c *Compute) createFetcher() func(ctx context.Context, req *wasmpb.FetchReq return nil, fmt.Errorf("workflow execution ID %q is invalid: %w", req.Metadata.WorkflowExecutionId, err) } + // best effort to decode the workflow name + var workflowName string + decodedWorkflowName, err := hex.DecodeString(req.Metadata.WorkflowName) + if err != nil { + c.log.Errorf("failed to decode WorkflowName %q: %v", req.Metadata.WorkflowName, err) + workflowName = req.Metadata.WorkflowName + } else { + workflowName = string(decodedWorkflowName) + } + cma := c.emitter.With( platform.KeyWorkflowID, req.Metadata.WorkflowId, - platform.KeyWorkflowName, req.Metadata.WorkflowName, + platform.KeyWorkflowName, workflowName, platform.KeyWorkflowOwner, req.Metadata.WorkflowOwner, platform.KeyWorkflowExecutionID, req.Metadata.WorkflowExecutionId, timestampKey, time.Now().UTC().Format(time.RFC3339Nano), diff --git a/core/capabilities/targets/write_target.go b/core/capabilities/targets/write_target.go index 09a0bbd2b36..2adca542533 100644 --- a/core/capabilities/targets/write_target.go +++ b/core/capabilities/targets/write_target.go @@ -345,10 +345,21 @@ func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.Cap return capabilities.CapabilityResponse{}, nil case commontypes.Failed, commontypes.Fatal: cap.lggr.Error("Transaction failed", "request", request, "transaction", txID) + + // best effort to decode the workflow name + var workflowName string + decodedWorkflowName, err := hex.DecodeString(request.Metadata.WorkflowName) + if err != nil { + cap.lggr.Errorf("failed to decode WorkflowName %q: %v", request.Metadata.WorkflowName, err) + workflowName = request.Metadata.WorkflowName + } else { + workflowName = string(decodedWorkflowName) + } + msg := "failed to submit transaction with ID: " + txID.String() err = cap.emitter.With( platform.KeyWorkflowID, request.Metadata.WorkflowID, - platform.KeyWorkflowName, request.Metadata.WorkflowName, + platform.KeyWorkflowName, workflowName, platform.KeyWorkflowOwner, request.Metadata.WorkflowOwner, platform.KeyWorkflowExecutionID, request.Metadata.WorkflowExecutionID, ).Emit(ctx, msg) diff --git a/core/services/workflows/delegate.go b/core/services/workflows/delegate.go index fc8fe3fe840..3fb377d3edc 100644 --- a/core/services/workflows/delegate.go +++ b/core/services/workflows/delegate.go @@ -81,7 +81,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.Ser type noopSecretsFetcher struct{} -func (n *noopSecretsFetcher) SecretsFor(ctx context.Context, workflowOwner, workflowName, workflowID string) (map[string]string, error) { +func (n *noopSecretsFetcher) SecretsFor(ctx context.Context, workflowOwner, hexWorkflowName, workflowID string) (map[string]string, error) { return map[string]string{}, nil } diff --git a/core/services/workflows/engine.go b/core/services/workflows/engine.go index d153e53bc07..2aa3cfd129a 100644 --- a/core/services/workflows/engine.go +++ b/core/services/workflows/engine.go @@ -96,7 +96,7 @@ func (sucm *stepUpdateManager) len() int64 { } type secretsFetcher interface { - SecretsFor(ctx context.Context, workflowOwner, workflowName, workflowID string) (map[string]string, error) + SecretsFor(ctx context.Context, workflowOwner, hexWorkflowName, workflowID string) (map[string]string, error) } // Engine handles the lifecycle of a single workflow and its executions. diff --git a/core/services/workflows/engine_test.go b/core/services/workflows/engine_test.go index 95ac74f0c76..f4a382d6696 100644 --- a/core/services/workflows/engine_test.go +++ b/core/services/workflows/engine_test.go @@ -153,7 +153,7 @@ func newTestEngineWithYAMLSpec(t *testing.T, reg *coreCap.Registry, spec string, type mockSecretsFetcher struct{} -func (s mockSecretsFetcher) SecretsFor(ctx context.Context, workflowOwner, workflowName, workflowID string) (map[string]string, error) { +func (s mockSecretsFetcher) SecretsFor(ctx context.Context, workflowOwner, hexWorkflowName, workflowID string) (map[string]string, error) { return map[string]string{}, nil } @@ -1606,7 +1606,7 @@ type mockFetcher struct { retval map[string]string } -func (m *mockFetcher) SecretsFor(ctx context.Context, workflowOwner, workflowName, workflowID string) (map[string]string, error) { +func (m *mockFetcher) SecretsFor(ctx context.Context, workflowOwner, hexWorkflowName, workflowID string) (map[string]string, error) { return m.retval, nil } diff --git a/core/services/workflows/syncer/handler.go b/core/services/workflows/syncer/handler.go index cb4f013d502..4fd237e41a4 100644 --- a/core/services/workflows/syncer/handler.go +++ b/core/services/workflows/syncer/handler.go @@ -224,7 +224,7 @@ func (h *eventHandler) refreshSecrets(ctx context.Context, workflowOwner, workfl return updatedSecrets, nil } -func (h *eventHandler) SecretsFor(ctx context.Context, workflowOwner, workflowName, workflowID string) (map[string]string, error) { +func (h *eventHandler) SecretsFor(ctx context.Context, workflowOwner, hexWorkflowName, workflowID string) (map[string]string, error) { secretsURLHash, secretsPayload, err := h.orm.GetContentsByWorkflowID(ctx, workflowID) if err != nil { // The workflow record was found, but secrets_id was empty. @@ -238,10 +238,21 @@ func (h *eventHandler) SecretsFor(ctx context.Context, workflowOwner, workflowNa lastFetchedAt, ok := h.lastFetchedAtMap.Get(secretsURLHash) if !ok || h.clock.Now().Sub(lastFetchedAt) > h.secretsFreshnessDuration { - updatedSecrets, innerErr := h.refreshSecrets(ctx, workflowOwner, workflowName, workflowID, secretsURLHash) + updatedSecrets, innerErr := h.refreshSecrets(ctx, workflowOwner, hexWorkflowName, workflowID, secretsURLHash) if innerErr != nil { msg := fmt.Sprintf("could not refresh secrets: proceeding with stale secrets for workflowID %s: %s", workflowID, innerErr) h.lggr.Error(msg) + + // best effort to decode the workflow name + var workflowName string + decodedWorkflowName, innerErr2 := hex.DecodeString(hexWorkflowName) + if innerErr2 != nil { + h.lggr.Errorf("failed to decode WorkflowName %q: %v", hexWorkflowName, innerErr2) + workflowName = hexWorkflowName + } else { + workflowName = string(decodedWorkflowName) + } + logCustMsg( ctx, h.emitter.With(