-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an environment variable to set minimum voting period allowed #271
Conversation
WalkthroughThis update introduces a new environment variable for setting the minimum voting period in the configuration, along with enhancements to the voting period validation in two components. The minimum duration is now defined dynamically based on an environment variable rather than a hardcoded value. In addition, a new utility function ( Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application Startup
participant Env as Env Configuration
participant Parser as parse-duration
App->>Env: Read NEXT_PUBLIC_MINIMUM_VOTING_PERIOD
Env->>Parser: parseDuration(duration, default=1800)
Parser-->>Env: Return duration in seconds
Env-->>App: Set minimumVotingPeriod
sequenceDiagram
participant User
participant Form as Voting Period Form
participant Validator as Validation Logic
participant Util as secondsToHumanReadable
User->>Form: Enter voting period
Form->>Validator: Validate against env.minimumVotingPeriod
Validator->>Util: Convert min seconds to human-readable format
Util-->>Validator: Return formatted minimum period
Validator-->>Form: Return result/error message
Form-->>User: Display validation feedback
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This can use any human readable string for defining the voting period. By default it will be 30m (same as before this PR). Fixed liftedinit#268
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #271 +/- ##
==========================================
+ Coverage 54.48% 54.52% +0.03%
==========================================
Files 207 207
Lines 17727 17743 +16
==========================================
+ Hits 9659 9674 +15
- Misses 8068 8069 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
config/env.ts (1)
3-10
: Add unit tests for theparseDuration
function.The function is not covered by tests according to the static analysis hints. Since this is a critical function for parsing user input, it should be thoroughly tested with various input scenarios.
Would you like me to generate unit tests for the
parseDuration
function? The tests should cover:
- Valid duration strings (e.g., "30m", "1h", "2d")
- Invalid duration strings
- Undefined input
- Edge cases
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 6-6: config/env.ts#L6
Added line #L6 was not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lock
is excluded by!**/*.lock
📒 Files selected for processing (5)
.env.test
(1 hunks)components/groups/forms/groups/GroupPolicyForm.tsx
(2 hunks)components/groups/modals/updateGroupModal.tsx
(2 hunks)config/env.ts
(2 hunks)package.json
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .env.test
🧰 Additional context used
🧠 Learnings (1)
components/groups/forms/groups/GroupPolicyForm.tsx (1)
Learnt from: chalabi2
PR: liftedinit/manifest-app#161
File: components/groups/forms/groups/GroupPolicyForm.tsx:213-215
Timestamp: 2025-01-07T01:21:52.501Z
Learning: In the GroupPolicyForm component, the voting period validation only needs to handle the minimum 30-minute period error at the object level, which produces a string error message. Individual field validations for days, hours, minutes, and seconds don't produce error messages.
🪛 GitHub Check: codecov/patch
config/env.ts
[warning] 6-6: config/env.ts#L6
Added line #L6 was not covered by tests
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (4)
config/env.ts (1)
52-52
: LGTM! The implementation aligns with the PR objectives.The
minimumVotingPeriod
property correctly uses the new environment variable with a default of 30 minutes, maintaining backward compatibility.components/groups/forms/groups/GroupPolicyForm.tsx (1)
19-28
: LGTM! The validation schema changes align with the PR objectives and past learnings.The implementation correctly:
- Uses the configurable minimum voting period from environment variables
- Provides human-readable error messages
- Maintains field-level validations without error messages as per past learnings
components/groups/modals/updateGroupModal.tsx (1)
259-274
: LGTM! The validation schema changes include a smart optimization.The implementation correctly:
- Uses the configurable minimum voting period
- Provides human-readable error messages
- Smartly skips validation if voting period is not being updated (all values are 0)
package.json (1)
74-74
:✅ Verification successful
Verify the latest version of parse-duration for security updates.
Let's check if version
^2.1.3
is the latest secure version.
🌐 Web query:
What is the latest version of parse-duration npm package? Are there any known security vulnerabilities?
💡 Result:
The latest version of the
parse-duration
npm package is 2.1.3, published 14 hours ago (as of February 12, 2025) [4][10].Regarding security vulnerabilities:
- No direct vulnerabilities have been reported for
parse-duration
in Snyk's vulnerability database [5][8]- The package appears safe based on current security scans
- General npm vulnerabilities like supply chain attacks remain a theoretical risk for all packages [2], but no specific issues are documented for this particular utility
For optimal security:
npm install parse-duration@latestThis ensures you get the most recent patched version with any potential security fixes[4]. Always verify dependencies using tools like
npm audit
or Snyk[6] to monitor for future vulnerabilities[2][5].Citations:
- 1: https://github.com/stdlib-js/time-base-parse-duration
- 2: https://www.aquasec.com/cloud-native-academy/supply-chain-security/npm-vulnerabilities/
- 3: https://cve.mitre.org/cgi-bin/cvekey.cgi
- 4: https://www.npmjs.com/package/parse-duration
- 5: https://security.snyk.io/package/npm/parse-duration/1.0.2
- 6: https://snyk.io/node-js/npm
- 7: https://www.npmjs.com/package/@alwatr%2Fparse-duration
- 8: https://snyk.io/vuln/npm:gm-parse-duration
- 9: https://www.acunetix.com/vulnerabilities/sca/cve-2022-31083-vulnerability-in-npm-package-parse-server/
- 10: https://www.npmjs.com/package/parse-duration?activeTab=versions
Parse-Duration Dependency Verified
The latest version of the
parse-duration
package is indeed 2.1.3, and no known security vulnerabilities have been reported. The dependency is up-to-date, so no changes are needed. Remember to periodically run tools likenpm audit
or Snyk for ongoing security checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
This can use any human readable string for defining the voting period. By default it will be 30m (same as before this PR).
Fixed #268
Summary by CodeRabbit
New Features
Chores