Skip to content

Commit

Permalink
Fix error handling for received state with no-state
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Nov 6, 2024
1 parent d414684 commit 83674e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bin/augment_metadata
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
#

if [[ $# -lt 2 ]]; then
echo Usage: $0 SITE_DIR DEVICE_ID [PUBBER_OPTS...]
echo Usage: $0 SITE_DIR DEVICE_ID [METADATA_OPTS...]
false
fi

site_dir=$(realpath $1)
device_id=$2
shift 2
pubber_opts=$*
metadata_opts=$*

nostate=false
if [[ $pubber_opts =~ noState ]]; then
if [[ $metadata_opts =~ noState ]]; then
nostate=true
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public class SequenceBase {
public static final int SCHEMA_SCORE_TOTAL = 10;
public static final int CAPABILITY_SCORE = 1;
public static final String STATUS_LEVEL_VIOLATION = "STATUS_LEVEL";
public static final String RECEIVED_STATE_VIOLATION = "RECEIVED_STATE";
public static final String DEVICE_STATE_SCHEMA = "device_state";
private static final String ALL_CHANGES = "";
private static final int SEQUENCER_FUNCTIONS_VERSION = Validator.TOOLS_FUNCTIONS_VERSION;
Expand Down Expand Up @@ -1880,7 +1881,12 @@ private synchronized void handleUpdateMessage(String subTypeRaw,
isoConvert(stateCutoffThreshold), lastStart, txnId));
return;
}
checkState(deviceSupportsState(), "Received state update with no-state device");
if (!deviceSupportsState()) {
String violation = "Received state update with no-state device";
warning(violation);
deviceStateViolations.put(RECEIVED_STATE_VIOLATION, violation);
return;
}
boolean deltaState = RECV_STATE_DIFFERNATOR.isInitialized();
List<DiffEntry> stateChanges = RECV_STATE_DIFFERNATOR.computeChanges(converted);
Instant start = ofNullable(convertedState.timestamp).orElseGet(Date::new).toInstant();
Expand Down

0 comments on commit 83674e9

Please sign in to comment.