Skip to content

[Bug]: Using uploaded SmartModules returns error: 0: Is a directory (os error 21) #2292

@ajhunyady

Description

@ajhunyady

In glucose demo, I created the following SmartModule:

use fluvio_smartmodule::{smartmodule, Record, RecordData, Result};

#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct FullRecord {
    event_type: String,
    source_device_id: String,
    blood_glucose_value: u32,
    pub transmitter_id: String,
    geolocation: String,
    timestamp: i64,
}

#[smartmodule(filter_map)]
pub fn filter_map(record: &Record) -> Result<Option<(Option<RecordData>, RecordData)>> {
    let full_record = serde_json::from_slice::<FullRecord>(record.value.as_ref())?;

    if full_record.blood_glucose_value > 190 {
        let reading = format!("Device `{}` - high glucose: `{}`, timestamp `{}`", 
            full_record.transmitter_id, 
            full_record.blood_glucose_value,
            full_record.timestamp
        );
        Ok(Some((None, RecordData::from(reading))))
    } else {
        Ok(None)
    }
}

The SmartModule works well when invoked from the cli:

% fluvio consume glucose --filter-map filter-map-slack/target/wasm32-unknown-unknown/release/filter_map_slack.wasm -T=100
Consuming records starting 100 from the end of topic 'glucose'
Device `ok6j44yai5` - high glucose: `191`, timestamp `1649439262131`
Device `ok6j44yai5` - high glucose: `191`, timestamp `1649439263131`
Device `ok6j44yai5` - high glucose: `191`, timestamp `1649439275131`
Device `ok6j44yai5` - high glucose: `191`, timestamp `1649439283131`
Device `ok6j44yai5` - high glucose: `199`, timestamp `1649439296131`
Device `ok6j44yai5` - high glucose: `196`, timestamp `1649439300131`

But fails if I load and invoke the SM module I uploaded.

% fluvio sm create filter-map-slack --wasm-file filter-map-slack/target/wasm32-unknown-unknown/release/filter_map_slack.wasm
% fluvio consume glucose --filter-map filter-map-slack -T=100 
Error: 
   0: Is a directory (os error 21)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions