diff --git a/docs/v3/source/includes/concepts/_metadata.md.erb b/docs/v3/source/includes/concepts/_metadata.md.erb index 1c8900c4fc7..32eea9139c5 100644 --- a/docs/v3/source/includes/concepts/_metadata.md.erb +++ b/docs/v3/source/includes/concepts/_metadata.md.erb @@ -37,8 +37,8 @@ Only annotations with a prefix (e.g. `company.com/contacts`) are sent to service Examples may include (but are not limited to): -- `"contact info": "bob@example.com jane@example.com"` -- `"library versions": "Spring: 5.1, Redis Client: a184098. yaml parser: 38"` +- `"contact-info": "bob@example.com jane@example.com"` +- `"library-versions": "Spring: 5.1, Redis Client: a184098. yaml parser: 38"` - `"git-sha": "d56fe0367554ae5e878e37ed6c5b9a82f5995512"` #### Annotation keys diff --git a/spec/unit/messages/validators/metadata_validator_spec.rb b/spec/unit/messages/validators/metadata_validator_spec.rb index 25a41e55a18..1bb048a232e 100644 --- a/spec/unit/messages/validators/metadata_validator_spec.rb +++ b/spec/unit/messages/validators/metadata_validator_spec.rb @@ -81,6 +81,15 @@ def annotations end describe 'invalid keys' do + context 'when the key contains a space' do + let(:labels) { { 'potato mashed' => 'value' } } + + it 'is invalid' do + expect(subject).not_to be_valid + expect(subject.errors_on(:metadata)).to include("label key error: 'potato mashed' contains invalid characters") + end + end + context 'when the key contains one invalid character' do # for the 32nd-126th characters, excluding the ones inside of the %r() (32.chr..126.chr).to_a.reject { |c| %r{[\w\-._/\s]}.match(c) }.each do |c| @@ -366,6 +375,15 @@ def annotations end end + context 'when the annotations key contains a space' do + let(:annotations) { { 'potato mashed' => 'value' } } + + it 'is invalid' do + expect(subject).not_to be_valid + expect(subject.errors_on(:metadata)).to include("annotation key error: 'potato mashed' contains invalid characters") + end + end + context 'when the annotations key is an empty string' do let(:annotations) do {