WGU D482 FULL PAPER ACTUAL QUESTIONS
AND CORRECT ANSWERS VERIFIED
SOLUTIONS
◉ TASK 1: Log file name and configuration
Answer: Troubleshooting_009963434.log, format %(asctime)s -
%(levelname)s - %(message)s, INFO level, one logging.basicConfig
at module top; messages follow EVENT: [event] | ACTION: [action]
◉ TASK 1: The two handled runtime errors and their levels
Answer: KeyError (unknown equipment_type) logged ERROR;
ValueError/TypeError (bad or missing days) logged WARNING -
both in the /rent try/except
◉ TASK 1: Defend ERROR for equipment but WARNING for days
Answer: Severity maps to suspicion: equipment is a fixed dropdown
so an unknown value implies a crafted request (ERROR); days is free
text so typos are expected user error (WARNING)
◉ TASK 1: What does int(None) raise and when?
Answer: TypeError, when the days field is missing from the POST
entirely - that's why the WARNING handler catches (ValueError,
TypeError), not ValueError alone
, ◉ TASK 1: Why does days raise ValueError when zero or negative
inside the try?
Answer: It funnels the business rule into the same handled
WARNING path the report describes instead of a separate return
branch
◉ TASK 1: The two assertions
Answer: 1: validate_username asserts username is a non-empty
string; 2: /login asserts request.remote_addr matches an IPv4 regex
- each writes an INFO log when the assumption holds, which is the
B3 evidence
◉ TASK 1: What happens to assert under python -O, and the lesson
Answer: Assertions are stripped at optimize level 1, so they are
documentation of developer assumptions, never production input
validation; a failed assert during a request = 500, which is acceptable
for assumption violations
◉ TASK 1: The 4 rubric-cited tests
Answer: test_invalid_equipment_type_handled (KeyError path +
ERROR log), test_non_numeric_days_handled (ValueError path +
WARNING), test_negative_days_rejected (nonpositive days
ValueError), test_student_input_validation (allowlist + assertion) -
suite has 6 total, all must pass
AND CORRECT ANSWERS VERIFIED
SOLUTIONS
◉ TASK 1: Log file name and configuration
Answer: Troubleshooting_009963434.log, format %(asctime)s -
%(levelname)s - %(message)s, INFO level, one logging.basicConfig
at module top; messages follow EVENT: [event] | ACTION: [action]
◉ TASK 1: The two handled runtime errors and their levels
Answer: KeyError (unknown equipment_type) logged ERROR;
ValueError/TypeError (bad or missing days) logged WARNING -
both in the /rent try/except
◉ TASK 1: Defend ERROR for equipment but WARNING for days
Answer: Severity maps to suspicion: equipment is a fixed dropdown
so an unknown value implies a crafted request (ERROR); days is free
text so typos are expected user error (WARNING)
◉ TASK 1: What does int(None) raise and when?
Answer: TypeError, when the days field is missing from the POST
entirely - that's why the WARNING handler catches (ValueError,
TypeError), not ValueError alone
, ◉ TASK 1: Why does days raise ValueError when zero or negative
inside the try?
Answer: It funnels the business rule into the same handled
WARNING path the report describes instead of a separate return
branch
◉ TASK 1: The two assertions
Answer: 1: validate_username asserts username is a non-empty
string; 2: /login asserts request.remote_addr matches an IPv4 regex
- each writes an INFO log when the assumption holds, which is the
B3 evidence
◉ TASK 1: What happens to assert under python -O, and the lesson
Answer: Assertions are stripped at optimize level 1, so they are
documentation of developer assumptions, never production input
validation; a failed assert during a request = 500, which is acceptable
for assumption violations
◉ TASK 1: The 4 rubric-cited tests
Answer: test_invalid_equipment_type_handled (KeyError path +
ERROR log), test_non_numeric_days_handled (ValueError path +
WARNING), test_negative_days_rejected (nonpositive days
ValueError), test_student_input_validation (allowlist + assertion) -
suite has 6 total, all must pass