fix(schema): use v1.Model instead of v1.ModelConfig in validateConfig#170
fix(schema): use v1.Model instead of v1.ModelConfig in validateConfig#170pradhyum6144 wants to merge 1 commit intomodelpack:mainfrom
Conversation
Summary of ChangesHello @pradhyum6144, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the schema validation logic where the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug in validateConfig where it was unmarshaling into v1.ModelConfig instead of the full v1.Model, which made the pre-schema validation a no-op. The change to unmarshal into v1.Model is correct. Additionally, the pull request significantly improves test coverage by adding positive test cases, addressing a situation where the test suite would pass even with a validator that always failed. The changes are solid, and I have one minor suggestion for improving code clarity.
schema/validator.go
Outdated
|
|
||
| func validateConfig(buf []byte) error { | ||
| mc := v1.ModelConfig{} | ||
| mc := v1.Model{} |
There was a problem hiding this comment.
Fixes pre validation always succeeding due to wrong unmarshal target. Also adds positive test cases to TestConfig. Signed-off-by: pradhyum6144 <pradhyum314@gmail.com>
863b290 to
c9e0ca8
Compare
|
Could a maintainer please add the |
Summary
validateConfigwas unmarshaling input intov1.ModelConfig(the inner config block) instead ofv1.Model(the full document). Sincejson.Unmarshalsilently ignores unknown fields, the pre-schema type check always succeeded — making it a no-op.Details
validateConfigusedv1.ModelConfig{}as the unmarshal target. A fullModelJSON (withdescriptor,config,modelfs) would unmarshal into the tinyModelConfigstruct without error, so structural mismatches were never caught at this stage.v1.Model{}so the pre-validation actually checks the correct document shape.TestConfig— previously all 17 cases asserted failure, so a validator that always errored would still pass the entire suite.Testing
```
go test ./schema/ -run TestConfig -v ✓ PASS
go test ./schema/ -run TestValidateConfigExample -v ✓ PASS
go test ./... ✓ PASS
```