Skip to content

feat(quick-start): ship the mandi market and price-field mapping - #123

Merged
manjudr merged 18 commits into
developmentfrom
fix/122-mandi-price-ship-market-and-price-field-mapping
Nov 9, 2026
Merged

manjudr merged 18 commits into
developmentfrom
fix/122-mandi-price-ship-market-and-price-field-mapping

Conversation

@kelvinprabhu

@kelvinprabhu kelvinprabhu commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #122
Depends on OpenAgriNet/network-adapter#119 (closes OpenAgriNet/network-adapter#107)

Changes

Change Reason
quick-start/config/mappings/agmarknet/mandi-price.select.yaml replaced with network-adapter#119's mapping. Deployments fetch the mapping from this repo (AGMARKNET_MAPPING_URL, charts/registry-seed), not from network-adapter.
capability-examples/MandiPrice/select/select.json: marketCode: "1634" added to market. It sent marketName without a code, which the new mapping refuses with a 400.
api-collection/OpenAgriNet.api-collection.json: the same fix in the mandi select. Same refusal in the Postman run.

Behaviour after this

  • marketCode given: that market. Absent (with no marketName): the whole district.
  • marketName without marketCode: 400 market.marketName alone is insufficient; provide market.marketCode or omit market.marketName for district-wide search.
  • State, district, commodity and validity dates are mandatory; district must be numeric and state a 2-4 letter code (MH, not Maharashtra). Only the requested price fields come back.

Copy network-adapter#119's mandi-price.select.yaml, the file deployments
fetch through AGMARKNET_MAPPING_URL. marketCode is optional (absent means
the whole district), a marketName without marketCode is refused, state,
district, commodity and validity dates are mandatory, and only the
requested price fields are returned.

The MandiPrice select example and the API collection's mandi select sent
marketName without marketCode, which the new mapping refuses; both now
carry marketCode 1634 (Rahuri APMC).

Refs OpenAgriNet/network-adapter#119

@kelvinprabhu kelvinprabhu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@kelvinprabhu
kelvinprabhu changed the base branch from development to fix/122-mandi-price-ship-the-market-and-price-field-mapping-from-network-adapter119 November 4, 2026 08:49
@kelvinprabhu
kelvinprabhu changed the base branch from fix/122-mandi-price-ship-the-market-and-price-field-mapping-from-network-adapter119 to development November 4, 2026 08:50
@kelvinprabhu kelvinprabhu added bug Something isn't working adapter Adapter codebase (beckn-onix). Additive - use alongside a layer label labels Nov 4, 2026
@kelvinprabhu kelvinprabhu self-assigned this Nov 4, 2026
@kelvinprabhu
kelvinprabhu requested review from ameersohel45 and manjudr and removed request for manjudr November 4, 2026 08:52

@kelvinprabhu kelvinprabhu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@manjudr manjudr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. No self review

Problem

The review on 95d3448 has the body "Done" and zero inline comments. Nothing on the diff.

Recommendation

Walk the three files and leave inline comments, then re-request review. This is the gate; the findings below are what a self review would have caught.


2. The benchmark select template still sends a market name with no code, so every benchmark run now gets a 400

Problem

benchmark/capabilities/mandiprice/templates/select.json sends "market": {"marketName": "{{MARKET_NAME}}", "district": "{{DISTRICT}}", "state": "{{STATE}}"}. It has no marketCode -- it is the only MandiPrice payload left in this repo that does not. benchmark/capabilities/mandiprice/config/select.yaml:11 points at it.

That is the exact payload the new mapping refuses at mandi-price.select.yaml:87.

Recommendation

Add "marketCode": "{{MARKET_CODE}}" to the template and define MARKET_CODE wherever MARKET_NAME is defined.


Two more inline.

@manjudr manjudr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at b3ba08f0. All four findings are still open and none has a reply. The eleven commits since are all "sync the mandi mapping with network-adapter#119".


1. Still no self review

Problem

The review on 95d3448 says "Done". The one on 6 Nov 06:10 also says "Done". Neither has a single inline comment on the diff.

Recommendation

Go through the three files and leave comments on them, then re-request review.


2. The benchmark select template still has no marketCode, so every benchmark run gets a 400

Problem

benchmark/capabilities/mandiprice/templates/select.json still sends "market": {"marketName": "{{MARKET_NAME}}", "district": "{{DISTRICT}}", "state": "{{STATE}}"}. grep -c marketCode on it returns 0, and it is still the only MandiPrice payload in this repo without one. benchmark/capabilities/mandiprice/config/select.yaml:11 points at it.

The mapping this PR ships refuses that payload at line 38.

Recommendation

Add "marketCode": "{{MARKET_CODE}}" to the template and define MARKET_CODE alongside MARKET_NAME.


Two more on the existing threads.

…ict-wide example [#122]

The mapping refuses a market name without a code, so every benchmark
select got a 400. The generator now copies marketCode from the published
resource. district-wide.json selects a whole district with only district
and state.
@kelvinprabhu

Copy link
Copy Markdown
Collaborator Author

Benchmark finding fixed in 59dabb4: prepare-select-data now reads marketCode from the published resource and templates/select.json sends it as {{MARKET_CODE}}. Regenerated the 300 selects: every one carries a numeric marketCode, district and state, and a sample passes the shipped mapping (marketcode=528&districtcode=326&statecode=MP).

@kelvinprabhu

kelvinprabhu commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Re-review at b3ba08f0, status at a2cc06b:

@kelvinprabhu kelvinprabhu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Review Done

@kelvinprabhu
kelvinprabhu requested a review from manjudr November 6, 2026 09:27
kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 6, 2026
internal/shippedmappings holds the helmcharts base URL and one line per
provider; each mapping test points its constant there.

Refs OpenAgriNet/helmcharts#123 (review comment r4489737182)
Refs #128 (review comment r4491627003)
kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 6, 2026
Refs OpenAgriNet/helmcharts#123 (review comment r4489737182)
Refs #128 (review comment r4491627003)
kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 6, 2026
Drops internal/mappingurls; each mapping test holds its helmcharts URL.

Refs OpenAgriNet/helmcharts#123 (review comment r4489737182)
Refs #128 (review comment r4491627003)

@manjudr manjudr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at c3c7be0. The benchmark finding is fixed. The district-wide example was fixed and then un-fixed. Two new findings, one inline.


1. A fix was applied, reported as done, and then reverted

Problem

8ed2e01 added quick-start/capability-examples/MandiPrice/select/select (district-level).json, and the thread on select.json:55 says "Fixed in 8ed2e01". c3c7be0 deletes that file, with the commit body Refs #123 (review comment r4489737192) -- the same review comment that asked for it.

So the thread reads as resolved while the branch has gone back to where it started. quick-start/capability-examples/MandiPrice/select/ holds one file and it carries marketCode: "1634".

Recommendation

Restore the file from 8ed2e01. If it was dropped on purpose, say why on the thread and reopen it rather than closing it with a commit that removes the fix.


2. Still no self review

Problem

Three reviews on this PR, bodies "Done", "Done" and "Self Review Done". None carries an inline comment on the diff -- every comment by the author on this PR is a reply to one of mine.

59dabb4 changes benchmark/capabilities/mandiprice/tools/prepare-select-data/main.go, a Go file that was not in this PR when it opened and that nobody has commented on. Two more commits landed after "Self Review Done", one of them c3c7be0.

Recommendation

Walk the diff and leave comments on it, then re-request. This is the gate before a line-by-line review, and it has now been asked for twice.


3. The description quotes a 400 message the mapping does not emit

Problem

The body says:

marketName without marketCode: 400 market.marketName alone is not enough: send market.marketCode ...

quick-start/config/mappings/agmarknet/mandi-price.select.yaml:40 says:

market.marketName alone is insufficient; provide market.marketCode or omit market.marketName for district-wide search.

Recommendation

Quote the shipped string, or drop the quote and say the request is refused with a 400.


4. The state guard

Inline on quick-start/config/mappings/agmarknet/mandi-price.select.yaml:30. Raised on network-adapter#119 too, but it ships from here, so it blocks here.


Resolved

The benchmark template. 59dabb4 adds {{MARKET_CODE}} to templates/select.json:52 and fills it in prepare-select-data/main.go:340 from a.Market.MarketCode, which templates/catalog.json:74 writes as {{MARKET_ID}}. Traced end to end -- the published payload always carries a market code, so the generated selects do too.

The two copies of the mapping. Answer recorded: maintained by hand for now, mappings to come out of network-adapter in a follow-up. They are still byte-identical at 91ca538 -- I diffed them again. Link the follow-up issue on the thread so it does not get lost.

$match($ra.market.district, /^[0-9]+$/)
and $match($ra.market.state, /^[A-Za-z]{2,4}$/)
/* Mandatory: Agmarknet refuses a call without statecode. */
$exists($ra.market.state)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The state guard is weaker than the one on development

Problem

This check is existence only. The same guard on network-adapter's development checks the shape of both codes:

$match($ra.market.district, /^[0-9]+$/)
  and $match($ra.market.state, /^[A-Za-z]{2,4}$/)

The mapping this PR ships keeps the district half and drops the state half.

The pack calls state a "State name or governed code" with minLength: 1 and no pattern (MandiPrice/v0.1/attributes.yaml:125-128), so "state": "Chattisgarh" is pack-legal, passes this check, and goes upstream as statecode=Chattisgarh. Agmarknet takes the code -- capability-examples/MandiPrice/select/select.json sends "state": "MH". The caller gets a signed, spec-valid "no prices" for a state that has prices.

This repo is what deployments fetch (AGMARKNET_MAPPING_URL), so this is the copy that fails in the field.

Recommendation

Fix it on network-adapter#119 and re-sync here. The check becomes:

$exists($ra.market.state)
  and $count($match($ra.market.state, /^[A-Za-z]{2,4}$/)) > 0

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on OpenAgriNet/network-adapter#119 in 62f3d2bb and re-synced here in a2cc06b: state must match ^[A-Za-z]{2,4}$, so "Maharashtra" is refused with a 400. Test added: a state name where the upstream wants a code.

@manjudr

manjudr commented Nov 9, 2026

Copy link
Copy Markdown
Member

Finding 2 (self review) is withdrawn -- the self review is done, my mistake. Findings 1, 3 and 4 stand:

  • the district-wide example added in 8ed2e01 and deleted again in c3c7be0
  • the description quoting a 400 message the mapping does not emit
  • the state guard on mandi-price.select.yaml:30

@manjudr

manjudr commented Nov 9, 2026

Copy link
Copy Markdown
Member

Merge readiness

Not yet, and not before network-adapter#119.

The state guard (quick-start/config/mappings/agmarknet/mandi-price.select.yaml:30). This repo is what deployments fetch via AGMARKNET_MAPPING_URL, so the weakened guard ships from here: "state": "Maharashtra" instead of "MH" passes, goes upstream as statecode=Maharashtra, and the caller gets a signed "no prices" for a state that has prices. Fix it on #119 and re-sync.

Worth doing in the same pass, none blocking on its own:

  • the district-wide example, added in 8ed2e01 and deleted again in c3c7be0. It is the headline change of release: 0.2.0 #119 and nothing in this repo demonstrates it.
  • the description quoting a 400 message the shipped mapping does not emit.

Order: network-adapter#119 first, then re-sync here and merge. Merging this ahead of #119 deploys a mapping the adapter repo has not agreed to yet.

kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 9, 2026

@manjudr manjudr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at a2cc06b. Everything I raised is addressed.


Resolved

The state guard. Fixed on network-adapter#119 in 62f3d2b and re-synced here in a2cc06b. I diffed the two copies again -- byte-identical.

The district-wide example. Answered: covered by TestShippedMappingSearchesTheDistrictWithoutAMarketCode rather than by an example file. Fine -- the behaviour is pinned somewhere, which was the point.

The two copies of the mapping. Follow-up named: network-adapter#127 / #128 removes the local copies and points the tests here. That is the mechanism I was asking for.

The description. Now quotes the shipped 400 string exactly, and says state must be a 2-4 letter code.

The benchmark template. 59dabb4, traced end to end earlier: {{MARKET_CODE}} is filled from a.Market.MarketCode, which templates/catalog.json:74 writes as {{MARKET_ID}}.


Approved. Merge after network-adapter#119, since this ships that mapping.

@manjudr
manjudr merged commit b1861de into development Nov 9, 2026
@manjudr
manjudr deleted the fix/122-mandi-price-ship-market-and-price-field-mapping branch November 9, 2026 12:11
kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 11, 2026
kelvinprabhu added a commit to OpenAgriNet/network-adapter that referenced this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adapter Adapter codebase (beckn-onix). Additive - use alongside a layer label bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mandi price: ship the market and price-field mapping from network-adapter#119

2 participants