Skip to content

Make marketCode mandatory in mandi-price select #97

Open

Description

@kelvinprabhu

A mandi-price select without market.marketCode is currently sent to Agmarknet without a marketcode. The query then covers the whole district, and the on_select resources have no marketCode, so the caller can't tell which market a price belongs to.

Changes (config/mappings/agmarknet/mandi-price.select.yaml)

  • New guard: refuse a select whose market.marketCode is absent or empty, before Agmarknet is called.
  • on_select resources carry market.marketCode (the requested code), in the same place catalog-ondemand.yaml puts it.
  • Guards can set their own error code. Add an optional code field to mapping guards (requirement in pkg/plugin/implementation/jsonmapper/jsonmapper.go) and pass it to NewBadReqErr; without one, the default SCH_INVALID_FORMAT is unchanged. The missing marketCode and missing validity guards use SCH_REQUIRED_FIELD_MISSING.

Refusal returned to the caller
HTTP 400, signed NACK:

{"message":{"status":"NACK","error":{"code":"SCH_REQUIRED_FIELD_MISSING","message":"BAD Request: this capability needs a market code in market.marketCode, as the catalog lists it; without it the query widens to the whole district"}}}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions