Schematize message structure for resources and extensions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 523
- Forks
- 75
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 24
Description
Summary of the new feature / enhancement
As a developer working on DSC resources, extensions, or integrations,
I want to reference a JSON schema for messages that resources or extensions should emit,
So that I can validate my implementation without needing to refer to documentation.
Currently, developers need to rely on documentation and investigation in the repository to understand how to emit messages from their resources or extensions for DSC to consume and bubble up.
While we are in the process of documenting how to emit messages from resources and extensions, it would be even better to provide a JSON schema that enables developers to check their work and describes the expected contract in the same way that we describe the contracts for stdout.
Proposed technical implementation details (optional)
Currently, we do a basic check on the JSON structure for an emitted message:
We should define a type to more accurately represent this structure, which we could then derive a JSON Schema for (and simplify the implementation for this check), like:
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum CommandMessage {
Error(String),
Warn(String),
Info(String),
Debug(String),
Trace(String),
}
Then, in the log_stderr_line function, we can update the implementation to:
} else if let Ok(message_object) = serde_json::from_str<CommandMessage>(trace_line) {
match message_object {
CommandMessage::Error(message) => error!("PID {process_id}: {message}"),
CommandMessage::Warn(message) => warn!("PID {process_id}: {message}"),
CommandMessage::Info(message) => info!("PID {process_id}: {message}"),
CommandMessage::Debug(message) => debug!("PID {process_id}: {message}"),
CommandMessage::Trace(message) => trace!("PID {process_id}: {message}"),
}
} else {
When we eventually support sending structured data in addition to simple messages, we can provide a schema for that struct separately.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dsc_lib/src/dscresources/command_resource.rs at the basic JSON check around lines 917-932, then trace the log_stderr_line function. Define the message contract and derived JSON schema described in the issue, and verify that emitted message objects are handled through the intended parsing path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100