Configuration
Open editable lessonDiscover → Predict → Understand
How would you use configuration to deliver a reviewed business outcome?
In a business solution, configuration must have a declared input, a controlled operation and a verifiable outcome. Properties store string key/value configuration and may be scoped to script, user or document. The local simulator maps these scopes to one fictional store and documents that simplification. Cache is temporary and may miss early; code must work without it. Do not store secrets in downloadable backups or browser fields.
Apply this technique to Document approval system. Explain what must be validated before its output is used.
- Explain the actual source operations in configuration.
- Predict the declared fixture result and verify it independently.
- Connect the technique to a requirement, failure case and human acceptance criterion.
Five explained source examples
Working configuration management
Configuration and cache retrieval are distinct; a missing cache key returns null and requires recomputation.
function main() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("summary"));
}[
{
"line": 1,
"source": "function main() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 2,
"source": " const settings = PropertiesService.getScriptProperties();",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 3,
"source": " settings.setProperty(\"REPORT_TAB\", \"Sales\");",
"explanation": "Persist this string marker only after the intended operation completes."
},
{
"line": 4,
"source": " const cache = CacheService.getScriptCache();",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 5,
"source": " cache.put(\"summary\", \"400\", 60);",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 6,
"source": " console.log(settings.getProperty(\"REPORT_TAB\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 7,
"source": " console.log(cache.get(\"summary\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 8,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
}
]Exact expected local evidence
{
"logs": [
"Sales",
"400"
],
"error": null,
"resource": "logs",
"value": null
}Find the first incorrect operation
This deliberately changed operation uses cache.get("missing"). Predict the mismatch and compare its actual output with the reference.
function main() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("missing"));
}[
{
"line": 1,
"source": "function main() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 2,
"source": " const settings = PropertiesService.getScriptProperties();",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 3,
"source": " settings.setProperty(\"REPORT_TAB\", \"Sales\");",
"explanation": "Persist this string marker only after the intended operation completes."
},
{
"line": 4,
"source": " const cache = CacheService.getScriptCache();",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 5,
"source": " cache.put(\"summary\", \"400\", 60);",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 6,
"source": " console.log(settings.getProperty(\"REPORT_TAB\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 7,
"source": " console.log(cache.get(\"missing\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 8,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
}
]Exact expected local evidence
{
"logs": [
"Sales",
"null"
],
"error": null,
"resource": "logs",
"value": null
}Repeat the operation and inspect idempotency
Execute the same operation twice against retained fictional state. Explain whether it repeats reads, duplicates a created object or safely skips completed work. The trace records actual supported service calls.
function lessonAction() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("summary"));
}
function main() {
lessonAction();
lessonAction();
}[
{
"line": 1,
"source": "function lessonAction() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 2,
"source": " const settings = PropertiesService.getScriptProperties();",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 3,
"source": " settings.setProperty(\"REPORT_TAB\", \"Sales\");",
"explanation": "Persist this string marker only after the intended operation completes."
},
{
"line": 4,
"source": " const cache = CacheService.getScriptCache();",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 5,
"source": " cache.put(\"summary\", \"400\", 60);",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 6,
"source": " console.log(settings.getProperty(\"REPORT_TAB\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 7,
"source": " console.log(cache.get(\"summary\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 8,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 9,
"source": "function main() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 10,
"source": " lessonAction();",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 11,
"source": " lessonAction();",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 12,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
}
]Exact expected local evidence
{
"logs": [
"Sales",
"400",
"Sales",
"400"
],
"error": null,
"resource": "logs",
"value": null
}Add a diagnostic failure boundary
Separate entry, success and a rethrown failure. A failure marker must not masquerade as success and must not swallow the original error.
function lessonAction() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("summary"));
}
function main() {
console.log("Start: Configuration management");
try { lessonAction(); console.log("Completed operation"); }
catch(error) { console.error("Failed operation: " + error.message); throw error; }
}[
{
"line": 1,
"source": "function lessonAction() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 2,
"source": " const settings = PropertiesService.getScriptProperties();",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 3,
"source": " settings.setProperty(\"REPORT_TAB\", \"Sales\");",
"explanation": "Persist this string marker only after the intended operation completes."
},
{
"line": 4,
"source": " const cache = CacheService.getScriptCache();",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 5,
"source": " cache.put(\"summary\", \"400\", 60);",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 6,
"source": " console.log(settings.getProperty(\"REPORT_TAB\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 7,
"source": " console.log(cache.get(\"summary\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 8,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 9,
"source": "function main() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 10,
"source": " console.log(\"Start: Configuration management\");",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 11,
"source": " try { lessonAction(); console.log(\"Completed operation\"); }",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 12,
"source": " catch(error) { console.error(\"Failed operation: \" + error.message); throw error; }",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 13,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
}
]Exact expected local evidence
{
"logs": [
"Start: Configuration management",
"Sales",
"400",
"Completed operation"
],
"error": null,
"resource": "logs",
"value": null
}Executable service-call and result assertions
Inject recording service adapters that delegate to the same supported virtual operations. Compare actual arguments and logs with fixed authored expectations. Change the operation and verify that the assertion fails; this local contract does not certify Google integration.
function invokeLesson(e, SpreadsheetApp, DocumentApp, DriveApp, GmailApp, MailApp, FormApp, CalendarApp, SlidesApp, ScriptApp, PropertiesService, CacheService, LockService, HtmlService, UrlFetchApp, Utilities, console, Logger) {
function lessonAction() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("summary"));
}
return lessonAction(e);
}
// A local dependency-injection contract test: calls still delegate to supported adapters.
function main() {
const records = [];
function serializable(value) {
try { return JSON.parse(JSON.stringify(value)); } catch (error) { return "[non-serializable]"; }
}
function recordService(target, path) {
return new Proxy(target, {get(object, key) {
const value = object[key];
if (typeof value !== "function") return value;
return (...args) => {
const method = path + "." + String(key);
records.push({method, args: args.map(serializable)});
const result = value.apply(object, args);
if (Array.isArray(result)) return result.map((item, index) => item && typeof item === "object" && !Array.isArray(item) ? recordService(item, method + "()[" + index + "]") : item);
return result && typeof result === "object" && !Array.isArray(result) && !(result instanceof Date) ? recordService(result, method + "()") : result;
};
}});
}
function recordLog(...args) {
records.push({log: args.map(value => typeof value === "string" ? value : JSON.stringify(value)).join(" ")});
}
const capturedConsole = {log: recordLog, error: recordLog, warn: recordLog, info: recordLog};
invokeLesson(e, recordService(SpreadsheetApp, "SpreadsheetApp"), recordService(DocumentApp, "DocumentApp"), recordService(DriveApp, "DriveApp"), recordService(GmailApp, "GmailApp"), recordService(MailApp, "MailApp"), recordService(FormApp, "FormApp"), recordService(CalendarApp, "CalendarApp"), recordService(SlidesApp, "SlidesApp"), recordService(ScriptApp, "ScriptApp"), recordService(PropertiesService, "PropertiesService"), recordService(CacheService, "CacheService"), recordService(LockService, "LockService"), recordService(HtmlService, "HtmlService"), recordService(UrlFetchApp, "UrlFetchApp"), recordService(Utilities, "Utilities"), capturedConsole, capturedConsole);
const expected = [
{
"method": "PropertiesService.getScriptProperties",
"args": []
},
{
"method": "PropertiesService.getScriptProperties().setProperty",
"args": [
"REPORT_TAB",
"Sales"
]
},
{
"method": "CacheService.getScriptCache",
"args": []
},
{
"method": "CacheService.getScriptCache().put",
"args": [
"summary",
"400",
60
]
},
{
"method": "PropertiesService.getScriptProperties().getProperty",
"args": [
"REPORT_TAB"
]
},
{
"log": "Sales"
},
{
"method": "CacheService.getScriptCache().get",
"args": [
"summary"
]
},
{
"log": "400"
}
];
if (JSON.stringify(records) !== JSON.stringify(expected)) throw new Error("Contract mismatch: inspect actual calls and logs");
console.log("Contract assertions passed: lesson 92");
}[
{
"line": 1,
"source": "function invokeLesson(e, SpreadsheetApp, DocumentApp, DriveApp, GmailApp, MailApp, FormApp, CalendarApp, SlidesApp, ScriptApp, PropertiesService, CacheService, LockService, HtmlService, UrlFetchApp, Utilities, console, Logger) {",
"explanation": "Inject the recording adapters and console into the lesson function, including its helpers; preserve the main entry point."
},
{
"line": 2,
"source": "function lessonAction() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 3,
"source": " const settings = PropertiesService.getScriptProperties();",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 4,
"source": " settings.setProperty(\"REPORT_TAB\", \"Sales\");",
"explanation": "Persist this string marker only after the intended operation completes."
},
{
"line": 5,
"source": " const cache = CacheService.getScriptCache();",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 6,
"source": " cache.put(\"summary\", \"400\", 60);",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 7,
"source": " console.log(settings.getProperty(\"REPORT_TAB\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 8,
"source": " console.log(cache.get(\"summary\"));",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 9,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 10,
"source": " return lessonAction(e);",
"explanation": "Return a result or stop this branch; returning differs from logging."
},
{
"line": 11,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 12,
"source": "",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 13,
"source": "// A local dependency-injection contract test: calls still delegate to supported adapters.",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 14,
"source": "function main() {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 15,
"source": " const records = [];",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 16,
"source": " function serializable(value) {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 17,
"source": " try { return JSON.parse(JSON.stringify(value)); } catch (error) { return \"[non-serializable]\"; }",
"explanation": "Parse syntax before validating business fields; malformed JSON throws."
},
{
"line": 18,
"source": " }",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 19,
"source": " function recordService(target, path) {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 20,
"source": " return new Proxy(target, {get(object, key) {",
"explanation": "Intercept supported service method access for this local contract test; calls still delegate to the original fictional adapter."
},
{
"line": 21,
"source": " const value = object[key];",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 22,
"source": " if (typeof value !== \"function\") return value;",
"explanation": "Evaluate this condition and test both accepted and rejected branches."
},
{
"line": 23,
"source": " return (...args) => {",
"explanation": "Return a result or stop this branch; returning differs from logging."
},
{
"line": 24,
"source": " const method = path + \".\" + String(key);",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 25,
"source": " records.push({method, args: args.map(serializable)});",
"explanation": "Capture an actual method argument or console value for comparison with the frozen authored contract."
},
{
"line": 26,
"source": " const result = value.apply(object, args);",
"explanation": "Execute the actual supported adapter method with its original receiver and arguments; the recorder does not fabricate a successful result."
},
{
"line": 27,
"source": " if (Array.isArray(result)) return result.map((item, index) => item && typeof item === \"object\" && !Array.isArray(item) ? recordService(item, method + \"()[\" + index + \"]\") : item);",
"explanation": "Build a new output item for every input item, preserving the intended row shape."
},
{
"line": 28,
"source": " return result && typeof result === \"object\" && !Array.isArray(result) && !(result instanceof Date) ? recordService(result, method + \"()\") : result;",
"explanation": "Return a result or stop this branch; returning differs from logging."
},
{
"line": 29,
"source": " };",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 30,
"source": " }});",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 31,
"source": " }",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 32,
"source": " function recordLog(...args) {",
"explanation": "Define a named callable block; defining it does not invoke it."
},
{
"line": 33,
"source": " records.push({log: args.map(value => typeof value === \"string\" ? value : JSON.stringify(value)).join(\" \")});",
"explanation": "Capture an actual method argument or console value for comparison with the frozen authored contract."
},
{
"line": 34,
"source": " }",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 35,
"source": " const capturedConsole = {log: recordLog, error: recordLog, warn: recordLog, info: recordLog};",
"explanation": "Bind the named value for the operations below; referenced arrays and objects may still be mutable."
},
{
"line": 36,
"source": " invokeLesson(e, recordService(SpreadsheetApp, \"SpreadsheetApp\"), recordService(DocumentApp, \"DocumentApp\"), recordService(DriveApp, \"DriveApp\"), recordService(GmailApp, \"GmailApp\"), recordService(MailApp, \"MailApp\"), recordService(FormApp, \"FormApp\"), recordService(CalendarApp, \"CalendarApp\"), recordService(SlidesApp, \"SlidesApp\"), recordService(ScriptApp, \"ScriptApp\"), recordService(PropertiesService, \"PropertiesService\"), recordService(CacheService, \"CacheService\"), recordService(LockService, \"LockService\"), recordService(HtmlService, \"HtmlService\"), recordService(UrlFetchApp, \"UrlFetchApp\"), recordService(Utilities, \"Utilities\"), capturedConsole, capturedConsole);",
"explanation": "Inject the recording adapters and console into the lesson function, including its helpers; preserve the main entry point."
},
{
"line": 37,
"source": " const expected = [",
"explanation": "These are fixed authored expectations. They are not recalculated from the learner\u2019s changed source."
},
{
"line": 38,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 39,
"source": " \"method\": \"PropertiesService.getScriptProperties\",",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 40,
"source": " \"args\": []",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 41,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 42,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 43,
"source": " \"method\": \"PropertiesService.getScriptProperties().setProperty\",",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 44,
"source": " \"args\": [",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 45,
"source": " \"REPORT_TAB\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 46,
"source": " \"Sales\"",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 47,
"source": " ]",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 48,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 49,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 50,
"source": " \"method\": \"CacheService.getScriptCache\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 51,
"source": " \"args\": []",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 52,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 53,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 54,
"source": " \"method\": \"CacheService.getScriptCache().put\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 55,
"source": " \"args\": [",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 56,
"source": " \"summary\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 57,
"source": " \"400\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 58,
"source": " 60",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 59,
"source": " ]",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 60,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 61,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 62,
"source": " \"method\": \"PropertiesService.getScriptProperties().getProperty\",",
"explanation": "Resolve persisted string configuration; validate missing values and never print a secret."
},
{
"line": 63,
"source": " \"args\": [",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 64,
"source": " \"REPORT_TAB\"",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 65,
"source": " ]",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 66,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 67,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 68,
"source": " \"log\": \"Sales\"",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 69,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 70,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 71,
"source": " \"method\": \"CacheService.getScriptCache().get\",",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 72,
"source": " \"args\": [",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 73,
"source": " \"summary\"",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 74,
"source": " ]",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 75,
"source": " },",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 76,
"source": " {",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 77,
"source": " \"log\": \"400\"",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 78,
"source": " }",
"explanation": "Close the current block; indentation shows the scope."
},
{
"line": 79,
"source": " ];",
"explanation": "Follow this operation in the source and compare its exact arguments and effect with the authored explanation."
},
{
"line": 80,
"source": " if (JSON.stringify(records) !== JSON.stringify(expected)) throw new Error(\"Contract mismatch: inspect actual calls and logs\");",
"explanation": "Reject any changed call or result. This deterministic fixture comparison is not a general semantic-equivalence or Google integration test."
},
{
"line": 81,
"source": " console.log(\"Contract assertions passed: lesson 92\");",
"explanation": "Record this actual result; inspect side effects too rather than treating a log as success."
},
{
"line": 82,
"source": "}",
"explanation": "Close the current block; indentation shows the scope."
}
]Exact expected local evidence
{
"logs": [
"Contract assertions passed: lesson 92"
],
"error": null,
"resource": "logs",
"value": null
}Guided experiment
- Read Discover and the fixture source.
- Write your prediction before Run Example.
- Run, then inspect service calls and actual state.
- Load the broken example, use hints and repair it.
- Check against the authored fixture, explain the boundary and extend the solution.
Three hints
- Locate cache.get("missing") in the failing source and predict its effect before changing it.
- Compare the intended operation cache.get("summary") with the failing operation cache.get("missing"). Use the earliest different log or state value.
- Replace the relevant cache.get("missing") operation with cache.get("summary"); rerun on fresh sample and explain why the result now satisfies the contract.
Finished implementation
function main() {
const settings = PropertiesService.getScriptProperties();
settings.setProperty("REPORT_TAB", "Sales");
const cache = CacheService.getScriptCache();
cache.put("summary", "400", 60);
console.log(settings.getProperty("REPORT_TAB"));
console.log(cache.get("summary"));
}Mistakes and recovery
[ "Confusing cache.get(\"summary\") with cache.get(\"missing\").", "Running again on changed state and expecting the original fixture result.", "Treating fictional service execution as proof of permissions, quotas or live API behavior." ]
Choose main as the entry function, or use the exact entry required by the example. Use the Manual event for this example. If there is no console output inspect the logs preview and Execution Trace. Reset before comparing to the fixed sample contract. Unsupported Google methods fail visibly; inspect the supported-service reference rather than assuming a successful fixture is a Google integration test.
Reflect and extend
Explain why Configuration and cache retrieval are distinct; a missing cache key returns null and requires recomputation. Which operation provides the strongest evidence? Propose one independent input with an exact expected outcome, and state what must still be checked on Google.
Extend this operation for a second realistic dataset. Preserve the source records, define a normal and invalid case before execution, and write a rerun policy for side effects. Review the resulting source with a peer before authorizing real services.
AI prompts
- Explain this solution using current code and evidence.
- Help implement one changed requirement with independent tests.
- Review and debug the current source without requesting secrets.
Use actual current source, errors, expected evidence and changed requirements. Verify suggestions with independent tests.