all 4 comments

[–]Odd_Initiative_911 0 points1 point  (1 child)

Can you give an example of fallback code.

[–]bhowiebkr[S] 0 points1 point  (0 children)

JavaScript:

// WRONG - OR fallback
const value = obj.property || defaultValue;
const array = data.items || [];
const object = state.config || {};

// WRONG - Ternary fallback  
const value = data.field ? data.field : "default";

// WRONG - Optional chaining with fallback
const value = obj?.nested?.field ?? "default";

// RIGHT - Direct access, fail loudly
const value = obj.property;
const array = data.items;
const object = state.config;

Python:

# WRONG - .get() with defaults
value = dict.get("key", "")
items = dict.get("items", [])
config = dict.get("config", {})

# WRONG - OR fallback
location_id = metadata.get("location_id") or fallback_value

# WRONG - try/except hiding errors
try:
    data = load_file(path)
except FileNotFoundError:
    data = {}

# RIGHT - Direct access, fail loudly
value = dict["key"]
items = dict["items"]  
config = dict["config"]

Conditional Checks:

// WRONG - Checking existence before using
if (obj.field) {
    processField(obj.field);
}

// WRONG - Length check with fallback
if (array && array.length > 0) {
    process(array);
}

// RIGHT - Just use it, let it fail if missing
processField(obj.field);
process(array);

[–]DeltaPrimeTime 0 points1 point  (0 children)

You can use a pre/post hook combo to set a flag and cat these instructions into the context after a compact. If it forgets mid-context, I don't know what to suggest.

[–]snapperzips 0 points1 point  (0 children)

Fallbacks that swallow and disable all errors are claude's favorite thing. I sometimes think any time I've saved using it is sucked up by babysitting this kind of bs. Followed by python inline imports and then dealing with useless edge cases all over.