Skip to content

Refactor insertDayDiet to return DayDiet and throw on failure#1478

Draft
Codex wants to merge 2 commits intorc/v0.16.0from
codex/remove-nullability-insert-day-diet
Draft

Refactor insertDayDiet to return DayDiet and throw on failure#1478
Codex wants to merge 2 commits intorc/v0.16.0from
codex/remove-nullability-insert-day-diet

Conversation

@Codex
Copy link
Copy Markdown

@Codex Codex AI commented Mar 25, 2026

insertDayDiet now guarantees a DayDiet result or throws, removing nullable insert behavior and tightening downstream handling.

  • Domain contracts: insertDayDiet returns Promise<DayDiet> (non-null) across repository and gateway interfaces.
  • Infrastructure: Supabase and guest gateways now always return the created DayDiet; Supabase adds a guard for missing data.
  • Application: Day use case caches the inserted day and rethrows errors instead of swallowing nulls.
  • Docs & tests: Architecture guide updated to describe the non-null contract; new guest gateway test ensures insertion returns and persists a DayDiet.

Example:

// Supabase gateway
const inserted = await insertDayDiet(newDay) // returns DayDiet or throws
dayCacheStore.upsertToCache(inserted)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • test.supabase.co
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/macroflows/macroflows/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js --global cal/bin/git pull.rebase (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/macroflows/macroflows/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js hash-object (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/macroflows/macroflows/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js --skipLibCheck /usr/bin/cat roflows node nfig/composer/vendor/bin/git cat /pro�� o | grep &#34;physical id&#34; | sort |usrc/modules/diet/day-diet/infrastructure/guest/guestDayGateway.tuniq tr /usr/bin/sort roflows getconf /usr/sbin/git ss.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove nullability from insertDayDiet return type</issue_title>
<issue_description># Remove nullability from insertDayDiet return type

Description:
Refactor the insertDayDiet function so that it never returns null. Instead, ensure it always returns a valid result or throws a domain error. Update all usages and tests to reflect this change, and document the new behavior.

Scope:

  • src/modules/diet/day-diet/domain/dayDietRepository.ts
  • All modules and files that use insertDayDiet
  • Related tests and documentation

Motivation:
Removing nullability from the return type improves type safety, predictability, and reduces the risk of runtime errors. It also clarifies the contract for consumers of the API.

Acceptance Criteria:

  • insertDayDiet never returns null
  • All usages are updated to handle the new return type
  • All affected tests and documentation are updated

Additional Context:

  • Review all usages of insertDayDiet in the codebase
  • See docs/audit_domain_diet_day-diet.md for related notes

Environment:

  • App Version: v0.12.0-dev..5+issue.325
  • OS: Linux
  • Shell: zsh

Labels:

  • refactor
  • backend
  • complexity-medium
  • improvement

reportedBy: github-copilot.v1/github-issue-unified
</issue_description>

Comments on the Issue (you are @codex[agent] in this section)

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
macroflows Ready Ready Preview, Comment Mar 25, 2026 9:06pm

@Codex Codex AI changed the title [WIP] Refactor insertDayDiet to remove nullability from return type Refactor insertDayDiet to return DayDiet and throw on failure Mar 25, 2026
@Codex Codex AI requested a review from marcuscastelo March 25, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove nullability from insertDayDiet return type

2 participants