8000 fix: Ash best practices audit — bug fix and hardening by mwoods79 · Pull Request #106 · huddlz-hq/huddlz · GitHub
[go: up one dir, main page]

Skip to content

fix: Ash best practices audit — bug fix and hardening - #106

Merged
mwoods79 merged 4 commits into
mainfrom
refactor/ash-best-practices-audit
Mar 15, 2026
Merged

mwoods79 merged 4 commits into
mainfrom
refactor/ash-best-practices-audit

Conversation

@mwoods79
Copy link
Copy Markdown
Contributor

Summary

Full codebase audit for Ash best practices, code quality, and efficiency. Found and fixed 4 issues:

  • Fix broken GroupOrganizer policy check — the check pattern-matched %{group_id: group_id} at the top level, but Ash passes context as %{subject: %{arguments: %{group_id: ...}}}. This silently prevented organizers from using the add_member action (only owners and admins could add members).
  • Cap recurring huddl generation at 104 instances — the recursive generate_huddlz_from_template had no upper bound; a far-future repeat_until with weekly frequency could generate 260+ huddlz synchronously.
  • Add max_length constraints to 5 unbounded text attributes (Group.description, Group.location, Huddl.description, Huddl.physical_location, Huddl.virtual_link).
  • Log search errors instead of silently returning empty results.

Test plan

  • New test: organizer can use add_member (proves bug fix)
  • New test: recurrence caps at 104 instances
  • New tests: attribute constraint rejection for all 5 fields
  • All 571 existing tests pass
  • Credo clean
  • Verified GroupOrganizer bug via tidewave project_eval against live app

- Add @max_instances guard to prevent unbounded recursive generation
- A weekly recurrence with a far-future repeat_until could previously
  generate 260+ huddlz synchronously in a single request
- Match subject.arguments.group_id instead of top-level group_id
- The previous pattern never matched the Ash authorization context,
  silently preventing organizers from using the add_member action
- Aligns with GroupOwner and GroupMember check patterns
- Group.description: max 5000, Group.location: max 500
- Huddl.description: max 5000, Huddl.physical_location: max 500
- Huddl.virtual_link: max 2048
- Prevents unbounded text input on fields with no prior limits
- Add Logger.warning for failed huddl searches
- UI still degrades gracefully with empty results
@mwoods79
mwoods79 merged commit aa7b0e3 into main Mar 15, 2026
1 check passed
@mwoods79
mwoods79 deleted the refactor/ash-best-practices-audit branch March 15, 2026 15:14
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.

1 participant

0