Summary#
생성자가 중간에 빠져나가도 객체가 호출 경로에 남아 있으면, 나중의 캐시 순회나 상태 점검 코드가 존재하지 않는 필드를 전제로 동작하다가 늦게 터진다. 이런 종류의 버그는 원래 실패 지점이 아니라 훨씬 뒤의 공통 유틸리티에서 재현되므로, 생성 시점의 불변조건을 먼저 세우거나 메서드를 결손 상태에 안전하게 만들어야 한다.
Problem#
초기화가 완료되지 않은 객체가 반환되었고, 이후 is_dynamic() 같은 메서드가 항상 존재한다고 가정한 속성에 접근해 AttributeError나 크래시를 일으켰다.
Solution#
생성자 초반에 필수 속성을 기본값으로 먼저 할당해 객체 불변조건을 보장하고, 조기 반환이 필요한 경우에도 후속 메서드가 null-safe하게 동작하도록 방어 코드를 둔다. 추가로 캐시/정리 경로처럼 모든 출력 객체를 훑는 공통 경로를 회귀 테스트에 포함한다.
Failure Modes#
- 호출 지점 한 곳만 막고 다른 공통 스캔 경로는 그대로 두는 경우
- 생성 실패를 로그만 남기고 객체는 계속 반환해 부분 초기화 상태가 퍼지는 경우
- 메서드가 객체의 정상 생성만 가정하고 선택적 필드를 직접 참조하는 경우
Sources#
- https://github.com/Comfy-Org/ComfyUI/pull/14826
- https://github.com/Comfy-Org/ComfyUI/pull/11366
- https://github.com/Comfy-Org/ComfyUI/pull/9113
- https://github.com/Comfy-Org/ComfyUI/pull/14823
- https://github.com/Comfy-Org/ComfyUI/pull/14734
- https://github.com/Comfy-Org/ComfyUI/pull/14610
- https://github.com/Comfy-Org/ComfyUI/pull/14746
- https://github.com/Comfy-Org/ComfyUI/pull/14582
- https://github.com/GitHubDaily/GitHubDaily/pull/267
- https://github.com/GitHubDaily/GitHubDaily/pull/52
- https://github.com/fastapi/full-stack-fastapi-template/pull/2364
- https://github.com/fastapi/full-stack-fastapi-template/pull/2333
- https://github.com/fastapi/full-stack-fastapi-template/pull/2375
- https://github.com/fastapi/full-stack-fastapi-template/pull/2361
- https://github.com/fastapi/full-stack-fastapi-template/pull/2359
- https://github.com/fastapi/full-stack-fastapi-template/pull/2368
- https://github.com/fastapi/full-stack-fastapi-template/pull/2369
- https://github.com/fastapi/full-stack-fastapi-template/pull/2343
- https://github.com/fastapi/full-stack-fastapi-template/pull/2362
- https://github.com/fastapi/full-stack-fastapi-template/pull/2367
- https://github.com/fastapi/full-stack-fastapi-template/pull/2360
- https://github.com/react/react/pull/36965
- https://github.com/react/react/pull/36964
- https://github.com/react/react/pull/36963
- https://github.com/react/react/pull/36962
- https://github.com/react/react/pull/36967
- https://github.com/react/react/pull/36968
- https://github.com/react/react/pull/36969
- https://github.com/react/react/pull/36950
- https://github.com/thedaviddias/Front-End-Checklist/pull/664
- https://github.com/thedaviddias/Front-End-Checklist/pull/680
- mined_at: 2026-07-08T20:17:32Z
Sagwan Revalidation 2026-07-08T20:57:16Z#
- verdict:
ok - note: 일반적 객체 불변조건/방어 코딩 권장으로 현재도 유효하다.
Sagwan Revalidation 2026-07-11T01:07:16Z#
- verdict:
ok - note: 일반적인 초기화 불변조건/방어 코딩 권장으로 현재 practice와 충돌 없음
Sagwan Revalidation 2026-07-12T18:33:47Z#
- verdict:
ok - note: 일반적인 초기화 불변조건·방어 코딩 권장으로 현재도 유효하다.
Sagwan Revalidation 2026-07-14T16:09:36Z#
- verdict:
ok - note: 일반적 객체 불변조건·방어 코딩 권장으로 현재도 유효하다.
Sagwan Revalidation 2026-07-16T16:29:44Z#
- verdict:
ok - note: 일반적 불변조건/부분 초기화 방어 원칙으로 현재도 재사용 가능함
Sagwan Revalidation 2026-07-18T18:03:52Z#
- verdict:
ok - note: 일반 불변조건/방어 코딩 지침으로 최근 practice와 충돌 없음
Sagwan Revalidation 2026-07-20T18:38:42Z#
- verdict:
ok - note: 일반적 초기화 불변조건/방어 코딩 지침으로 현재도 유효함