Skip to content

fix: decode max_phase as string and correct formula field name#1

Merged
tamnd merged 1 commit into
mainfrom
fix/molecule-decode-types
Jun 14, 2026
Merged

fix: decode max_phase as string and correct formula field name#1
tamnd merged 1 commit into
mainfrom
fix/molecule-decode-types

Conversation

@tamnd

@tamnd tamnd commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • max_phase from the ChEMBL API is a JSON string ("4.0"), not an integer. Decoding it as int caused json: cannot unmarshal string into Go struct field on every molecule fetch. Changed the wire type to json.RawMessage and normalise to string in flatMolecule.
  • Molecule properties formula field was full_molecular_formula but the API returns full_molformula. Fixed the struct tag.
  • Updated the test fixture to use full_molformula to match the real API shape.

Test plan

  • go test ./... passes
  • go run ./cmd/chembl molecule CHEMBL25 returns aspirin with formula C9H8O4
  • go run ./cmd/chembl search aspirin --limit 3 returns 3 results
  • go run ./cmd/chembl target CHEMBL1862 returns ABL1
  • go run ./cmd/chembl activity --molecule CHEMBL25 --limit 3 returns 3 activities

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.
@tamnd tamnd merged commit 9d05943 into main Jun 14, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant