tink: grpc-server do not return error when creating bad template
Expected Behaviour
If one provides bad template to gRPC call to create a template, error should be returned.
Current Behaviour
Currently no error is returned, but no template is created either.
Steps to Reproduce (for bugs)
Add following unit test case:
diff --git grpc-server/template_test.go grpc-server/template_test.go
index 84fc6b3..fc67766 100644
--- grpc-server/template_test.go
+++ grpc-server/template_test.go
@@ -90,6 +90,18 @@ func TestCreateTemplate(t *testing.T) {
expectedError: true,
},
},
+ "BadYAML": {
+ args: args{
+ db: mock.DB{
+ TemplateDB: make(map[string]interface{}),
+ },
+ name: "template_1",
+ template: `"foo`,
+ },
+ want: want{
+ expectedError: true,
+ },
+ },
}
for name := range testCases {
It can also be reproduced with tink CLI:
- Create file
bar.yamlwith content:"foo(intentional not closed quote) - Run
template create --name foo --path bar.yaml - Error should be returned.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (13 by maintainers)
oh I see I very much missed that. Yes the validation wasn’t very strict and #315 should definitely address this.
@JayHelton I think you don’t need to set up Tinkerbell to resolve this issue, just in case, as the issue can be reproduced with unit tests.
However, I noticed, that the database mock has different implementation than the actual server, which might make a difference here, as right now the database implementation does the validation of the data. I’m pretty sure validation should be happening before data is written to the database, but it might be out of scope for this issue.
Hello @JayHelton ! That’s great! please follow one of the setup guides in our documentation https://tinkerbell.org/docs/ and feel free to join our Slack community if you need any help or you have questions https://tinkerbell.org/community/
have a nice hacktoberfest and a good weekend!