Skip to content

Dapr apphost fails to startup if you set parameter without explicit value #958

@gabynevada

Description

@gabynevada

Describe the bug

When you defined a parameter and leave it without a value to set it later on the dashboard the app crashes due to dapr reading the parameter values at startup.

Regression

No response

Steps to reproduce

Add a parameter to the example app and set the redis password.

var builder = DistributedApplication.CreateBuilder(args);

var redisPassword = builder.AddParameter("redisPassword", secret: true);
var redis = builder.AddRedis("redis", password: redisPassword).WithRedisInsight();


var stateStore = builder.AddDaprStateStore("statestore")
    .WaitFor(redis);

var redisHost= redis.Resource.PrimaryEndpoint.Property(EndpointProperty.Host);
var redisPort = redis.Resource.PrimaryEndpoint.Property(EndpointProperty.Port);

var pubSub = builder
  .AddDaprPubSub("pubsub")
  .WithMetadata(
    "redisHost",
    ReferenceExpression.Create(
      $"{redisHost}:{redisPort}"
    )
  )
  .WaitFor(redis);

if (redis.Resource.PasswordParameter is not null)
{
    pubSub.WithMetadata("redisPassword", redis.Resource.PasswordParameter);
}

builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceA>("servicea")
       .WithDaprSidecar(sidecar =>
       {
           sidecar.WithReference(stateStore).WithReference(pubSub);
       }).WaitFor(redis);

builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceB>("serviceb")
       .WithDaprSidecar(sidecar => sidecar.WithReference(pubSub))
       .WaitFor(redis);

// console app with no appPort (sender only)
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceC>("servicec")
       .WithDaprSidecar(sidecar => sidecar.WithReference(stateStore))
       .WaitFor(redis);

builder.Build().Run();

Expected behavior

The apphost starts and waits for the input fo the password before creating the dapr component reliant on it.

Screenshots

No response

IDE and version

VS Code

IDE version

No response

Nuget packages

CommunityToolkit.Aspire.Hosting.Azure.Dapr 9.9.0

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions