fix: decode max_phase as string and correct formula field name#1
Merged
Conversation
The ChEMBL API returns max_phase as a JSON string ("4.0") not an int,
causing an unmarshal error on every molecule fetch. Decode it via
json.RawMessage and normalise to string. Also fix the molecule properties
field name: the API uses full_molformula, not full_molecular_formula.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_phasefrom the ChEMBL API is a JSON string ("4.0"), not an integer. Decoding it asintcausedjson: cannot unmarshal string into Go struct fieldon every molecule fetch. Changed the wire type tojson.RawMessageand normalise to string inflatMolecule.full_molecular_formulabut the API returnsfull_molformula. Fixed the struct tag.full_molformulato match the real API shape.Test plan
go test ./...passesgo run ./cmd/chembl molecule CHEMBL25returns aspirin with formula C9H8O4go run ./cmd/chembl search aspirin --limit 3returns 3 resultsgo run ./cmd/chembl target CHEMBL1862returns ABL1go run ./cmd/chembl activity --molecule CHEMBL25 --limit 3returns 3 activities