Skip to content

refactor: enforce non-null constraints on notification fields#1807

Merged
YoshihitoAso merged 3 commits intodev-26.6from
refactor/#1794
Apr 8, 2026
Merged

refactor: enforce non-null constraints on notification fields#1807
YoshihitoAso merged 3 commits intodev-26.6from
refactor/#1794

Conversation

@purplesmoke05
Copy link
Copy Markdown
Member

📌 Description

This PR updates notification nullability for issue #1794.

Fields that should always exist are aligned across the migration, ORM model, and API schema. address stays nullable because some notification types do not have an address.

✅ Related Issues

🔄 Changes

  • Added a migration to make these notification fields NOT NULL:
    • notification_type
    • priority
    • is_read
    • is_flagged
    • is_deleted
    • block_timestamp
    • metainfo
  • Backfilled priority with 0 and boolean flags with False
  • Deleted invalid notification rows with missing notification_type, block_timestamp, or metainfo

📌 Checklist

  • I have added tests where necessary.
  • I have updated the documentation where necessary.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Coverage

Coverage Report •
FileStmtsMissBranchBrPartCoverMissing
app/api/routers
   notification.py106944791%101, 105, 147, 172, 212, 247, 301, 306, 357
app/model/db
   notification.py7246394%42, 53, 132, 141
app/model/schema
   notification.py78000100% 
tests/app
   notification_Notifications_GET_test.py154000100% 
TOTAL378551671368875795% 

Tests Skipped Failures Errors Time
1269 0 💤 0 ❌ 0 🔥 10m 11s ⏱️

@purplesmoke05 purplesmoke05 marked this pull request as ready for review April 7, 2026 10:13
@YoshihitoAso YoshihitoAso requested a review from Copilot April 8, 2026 09:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enforces non-null guarantees for persisted notification records by aligning DB constraints, ORM typing, and API schema expectations (issue #1794), while keeping address/account_address nullable for notification types that don’t have an address.

Changes:

  • Added an Alembic migration to backfill defaults, delete invalid rows, and set several notification columns to NOT NULL.
  • Updated the SQLAlchemy Notification model and schema typings to reflect non-null fields, and allowed account_address to be nullable in the API schema.
  • Updated API router serialization/type-check scaffolding and expanded migration/API tests to cover the new constraints and nullable account_address.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
migrations/versions/93f1494c3975_v26_6_0_feature_1794.py Backfills/deletes invalid notifications and applies NOT NULL constraints (incl. JSON-null handling for metainfo).
app/model/db/notification.py Makes several notification columns non-nullable and centralizes datetime formatting used by API serialization.
app/model/schema/notification.py Updates response typing to require non-null fields and to allow account_address to be null.
app/api/routers/notification.py Simplifies notification serialization and removes redundant null assertions now covered by DB/model guarantees.
docs/ibet_wallet_api.yaml Updates OpenAPI schema to allow account_address: null.
tests/migrations/upgrade_test.py Extends migration upgrade test to validate the new notification nullability/backfill/delete behavior.
tests/app/notification_Notifications_GET_test.py Adds coverage for a notification with account_address/address as None and updates expected counts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@YoshihitoAso YoshihitoAso merged commit 2832470 into dev-26.6 Apr 8, 2026
16 checks passed
@YoshihitoAso YoshihitoAso deleted the refactor/#1794 branch April 8, 2026 14:43
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.

[REFACTOR] Normalize notification nullability in API and ORM models

3 participants