Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

payload has no content attribute in process_job method #28

Open
AissaGeek opened this issue Oct 29, 2024 · 0 comments
Open

payload has no content attribute in process_job method #28

AissaGeek opened this issue Oct 29, 2024 · 0 comments

Comments

@AissaGeek
Copy link

Description:

The code attempts to access job.get('payload', {}).get('content', {}).get('size'), but it seems that the main payload dictionary does not have a content key.

Example of a payload

{
   "topic":"cache/a/wis2/dz-meteoalgerie/data/core/weather/surface-based-observations/synop",
   "payload":{
      "id":"1dc16d64-8d99-11ef-b4ca-e43d1a213544",
      "type":"Feature",
      "version":"v04",
      "geometry":{
         "type":"Point",
         "coordinates":[
            6.11667,
            20.56667
         ]
      },
      "properties":{
         "data_id":"dz-meteoalgerie/data/core/weather/surface-based-observations/synop/WIGOS_0-20000-0-60693_20241018T210000",
         "datetime":"2024-10-18T21:00:00Z",
         "pubtime":"2024-10-18T21:26:05Z",
         "integrity":{
            "method":"sha512",
            "value":"2H+KOEeVv2mf+FRJNnEvXISrhdPbcrx8/wGTjALidnMD4wHlOm/VnFH9pJ8NRbzGQ+0h3AcxLwIsjzcxOVNd3g=="
         },
         "content":{
            "encoding":"base64",
            "value":"QlVGUgAA9wQAABYAABUAAAAAAAEAHAAH6AoSFQAAAAALAAABgMGWx1AAAMoABOIAAANjA2OTMAAAAAAAAAAAAAAHlapKcQIKoipIAAAAAAAAAAAAAAAAAv0UlUBUWw2jf7p///////////////////////////////////////////4P/vKFAAAP/yP+T/////////////////////H+lKf//+/R///////////////////////////////+BP7f///7+3///////////v0f/7///////////////////9+j//////////////////////+ANzc3Nw==",
            "size":247
         },
         "wigos_station_identifier":"0-20000-0-60693"
      },
      "links":[
         {
            "rel":"canonical",
            "type":"application/x-bufr",
            "href":"https://wis2.dwd.de/gc/24h/dz-meteoalgerie/eaa5cc04-f9c1-4493-afda-fa096eafdb12__WIGOS_0-20000-0-60693_20241018T210000.bufr4",
            "length":247
         },
         {
            "rel":"via",
            "type":"text/html",
            "href":"https://oscar.wmo.int/surface/#/search/station/stationReportDetails/0-20000-0-60693"
         }
      ]
   },
   "target":"surface-obs"
}

As you may notice content dict is inside properties. This could lead to unexpected behavior or errors if the content key is expected to be present.

Proposed Solution

Consider checking the presence of content inside payload or inside properties

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant