-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Read an ACL policy that do not exists using CLI results in panic #16483
Copy link
Copy link
Closed
Description
Overview of the Issue
When reading an ACL policy that does not exist using the CLI, it results in a panic.
However, when using the flag -format=json, the panic does not occur and it returns the string null
Reproduction Steps
With ACL initialized, execute in a server agent consul acl policy read -token=<consul token> -name does-not-exist
Consul info for both Client and Server
Server info
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 0
build:
prerelease =
revision = 53f65dc3
version = 1.15.0
version_metadata =
consul:
acl = enabled
bootstrap = false
known_datacenters = 1
leader = false
leader_addr = 10.99.0.13:8300
server = true
raft:
applied_index = 269
commit_index = 269
fsm_pending = 0
last_contact = 29.57435ms
last_log_index = 269
last_log_term = 3
last_snapshot_index = 0
last_snapshot_term = 0
latest_configuration = [{Suffrage:Voter ID:3239f2d0-0c18-f1ad-9879-f3cc68196fff Address:10.99.0.11:8300} {Suffrage:Voter ID:a9074442-03f0-ec2c-7138-13da2bd0f7ba Address:10.99.0.12:8300} {Suffrage:Voter ID:db2e41cc-8b21-6ffa-401d-429c5ba13707 Address:10.99.0.13:8300}]
latest_configuration_index = 0
num_peers = 2
protocol_version = 3
protocol_version_max = 3
protocol_version_min = 0
snapshot_version_max = 1
snapshot_version_min = 0
state = Follower
term = 3
runtime:
arch = amd64
cpu_count = 8
goroutines = 145
max_procs = 8
os = linux
version = go1.20.1
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 3
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 5
members = 3
query_queue = 0
query_time = 1
serf_wan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 1
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 3
members = 3
query_queue = 0
query_time = 1
data_dir = "/opt/consul"
server = true
advertise_addr = "{{ GetInterfaceIP \"eth0\" }}"
client_addr = "127.0.0.1 {{ GetInterfaceIP \"eth0\" }}"
primary_datacenter = "dc1"
bootstrap_expect = 3
retry_join = [
"10.99.0.11",
"10.99.0.12",
"10.99.0.13",
]
tls {
defaults {
ca_file = "/etc/certs.d/ca.pem"
cert_file = "/etc/certs.d/cert.pem"
key_file = "/etc/certs.d/private_key.pem"
verify_incoming = true
verify_outgoing = true
}
internal_rpc {
verify_server_hostname = true
}
}
auto_encrypt {
allow_tls = true
}
encrypt = "redacted"
ports {
https = 8501
grpc = 8502
grpc_tls = 8503
}
connect {
enabled = true
}
acl {
enabled = true
default_policy = "deny"
enable_token_persistence = true
tokens {
initial_management = "redacted"
agent = "redacted"
}
}
ui_config {
enabled = true
}
telemetry {
prometheus_retention_time = "10s"
disable_hostname = true
}
Operating system and Environment details
OS: Ubuntu 22.04
Arch: Amd64
Platform: LXD Container
Log Fragments
The output of the panic:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe47c9a]
goroutine 1 [running]:
github.com/hashicorp/consul/command/acl/policy.(*prettyFormatter).FormatPolicy(0xc000212000, 0x0)
github.com/hashicorp/consul/command/acl/policy/formatter.go:53 +0x3a
github.com/hashicorp/consul/command/acl/policy/read.(*cmd).Run(0xc0002351f0, {0xc000138040?, 0xffffffffffffffff?, 0x0?})
github.com/hashicorp/consul/command/acl/policy/read/policy_read.go:100 +0x397
github.com/mitchellh/cli.(*CLI).Run(0xc0008d1900)
github.com/mitchellh/cli@v1.1.0/cli.go:260 +0x5f8
main.realMain()
github.com/hashicorp/consul/main.go:48 +0x40f
main.main()
github.com/hashicorp/consul/main.go:18 +0x19
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels