ConsulConfigProperties#getAclToken() remains null although spring.cloud.consul.token is available in the Environment
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- java, spring-boot
调研方向
从 ConsulConfigProperties 和 issue 中显示的 aclToken 字段开始,然后跟踪属性来自 ConfigData Vault 源时其 @Value 表达式是如何解析的。将该路径与 Environment.getProperty 和常规的 @Value 注入进行比较;完成的标准是确定 null 值是否符合预期,或通过有针对性的覆盖率测试复现回归问题。
由索引模型根据 Issue 内容生成。
描述
Description
I'm investigating the behavior of ConsulConfigProperties#getAclToken() in Spring Cloud Consul and I'm not sure whether this is an intended behavior or a bug.
In my application, spring.cloud.consul.token is successfully loaded from Spring Cloud Vault through ConfigData.
The property is available in the Environment, and a regular @Value("${spring.cloud.consul.token}") injection works correctly.
However, ConsulConfigProperties#getAclToken() always returns null.
Versions
- Spring Boot: 3.5.14
- Spring Cloud Release Train: 2025.0.1
- spring-cloud-consul-config: 4.3.1
Configuration
spring:
config:
import:
- vault://
- consul://
cloud:
consul:
config:
enabled: true
The Consul ACL token is stored in Vault under:
spring.cloud.consul.token
Observations
The following values are logged during application startup:
Environment.getProperty("spring.cloud.consul.token")
=> 08****35 (masked intentionally)
ConsulConfigProperties#getAclToken()
=> null
The property source owning the property is:
dev-secret/consul-configs
Additional verification
To make sure this was not a configuration issue, I performed the following checks:
Environment.getProperty("spring.cloud.consul.token")returns the expected value.- A regular Spring bean using
@Value("${spring.cloud.consul.token}")
private String token;
receives the correct value.
-
ConsulConfigPropertiesitself is properly bound:enableddefaultContextprefixes
all contain the expected values.
-
Using reflection confirms that the internal
aclTokenfield is stillnull.
Field field = ConsulConfigProperties.class.getDeclaredField("aclToken");
field.setAccessible(true);
System.out.println(field.get(consulConfigProperties));
// null
The field is annotated with:
@Value("${consul.token:${CONSUL_TOKEN:${spring.cloud.consul.token:${SPRING_CLOUD_CONSUL_TOKEN:}}}}")
private String aclToken;
and the annotation is present at runtime.
Question
Is this expected?
Should ConsulConfigProperties#getAclToken() be populated from spring.cloud.consul.token, or is the aclToken field intentionally left unset when using ConfigData (Vault)?
If it is expected to be populated, this appears to be a regression because:
- the property exists in the
Environment, @Valueworks on regular Spring beans,- only the
aclTokenfield insideConsulConfigPropertiesremainsnull.
- 主要语言
- Java
- 星标
- 821
- 派生
- 540
- 平均合并
- 12 小时 56 分钟
- 30 天内合并 PR
- 15
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-cloud/spring-cloud-consul 的其他 Issue
-
waiting-for-triage
难度 2/5 1-3 小时 新手友好度 68/100
spring-cloud/spring-cloud-consul#984 ·
维护者通常 1 天内回复
-
spring.cloud.consul.config.prefixes documentation update可能重新可做 关联的 PR 已关闭且未合并。 未关闭documentation
难度 1/5 1-3 小时 新手友好度 78/100
spring-cloud/spring-cloud-consul#746 · 5 条评论 ·
维护者通常 1 天内回复
-
Migrating from Spring boot 3.5.11 to 4.0.3 : reregister-service-on-failure not working anymore可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭waiting-for-triage
难度 4/5 3-5 天 新手友好度 48/100
spring-cloud/spring-cloud-consul#954 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
waiting-for-triage
难度 3/5 1-2 天 新手友好度 52/100
spring-cloud/spring-cloud-consul#951 · 4 条评论 ·
维护者通常 1 天内回复
-
waiting-for-triage
难度 4/5 3-5 天 新手友好度 45/100
spring-cloud/spring-cloud-consul#950 · 4 条评论 ·
维护者通常 1 天内回复
查看 spring-cloud/spring-cloud-consul 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefix可能已有人在做 @ItsDeadlyProgrammer 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
appsmithorg/appsmith#42471 · 1 条评论 ·
维护者通常 2 天内回复
-
code-maintenance
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
-
bug priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 82/100
carlos-emr/carlos#5258 ·
维护者通常 1 天内回复