Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/v3/source/includes/concepts/_metadata.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions spec/unit/messages/validators/metadata_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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
{
Expand Down
Loading