Skip to content

O7E-269 updated seed with user#47

Merged
Tiitmouse merged 3 commits intomainfrom
O7E-271_IT_unregisterDevice
Jun 2, 2025
Merged

O7E-269 updated seed with user#47
Tiitmouse merged 3 commits intomainfrom
O7E-271_IT_unregisterDevice

Conversation

@Tiitmouse
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features

    • Added automated seeding of initial users and devices, including a superadmin and test accounts, during application startup.
  • Bug Fixes

    • Improved error handling during user and device creation, ensuring errors are properly reported instead of causing unexpected panics.
  • Refactor

    • Updated device manager and seeding logic to use dependency injection for improved maintainability and consistency.

Summary by CodeRabbit

  • New Features

    • Added functionality to seed initial user data, including automatic creation of a test user and device when in test environment.
  • Bug Fixes

    • Improved error handling during superadmin creation, with errors now properly reported instead of causing panics or silent failures.

Walkthrough

The changes refactor the superadmin seeding process by renaming and modifying its error handling, introduce a new user seeding mechanism for both superadmin and test users (and a test device), and update the main entry point to use the new seeding method. The device manager initialization was changed to use dependency injection rather than explicit parameters. Error handling is now propagated instead of causing panics.

Changes

File(s) Change Summary
main.go Replaces seed.CreateSuperAdmin() call with seed.Insert().
util/seed/superadmin.go Renames CreateSuperAdmin to createSuperAdmin, changes error handling to return errors.
util/seed/user.go Adds new file with Insert, createUser, and createDevice functions to seed users/devices.
service/loginService.go Removes parameters from device.NewDeviceManager() call in NewLoginService.
util/device/registerDevice.go Changes NewDeviceManager to parameterless, uses dependency injection to initialize fields.

Sequence Diagram(s)

sequenceDiagram
    participant Main
    participant Seed
    participant SuperAdminSeeder
    participant UserSeeder
    participant DeviceManager

    Main->>Seed: Insert()
    Seed->>SuperAdminSeeder: createSuperAdmin()
    SuperAdminSeeder-->>Seed: error or nil
    alt Environment is test
        Seed->>UserSeeder: createUser()
        UserSeeder-->>Seed: error or nil
        Seed->>DeviceManager: createDevice()
        DeviceManager-->>Seed: error or nil
    end
    Seed-->>Main: error or nil
Loading

Possibly related PRs

Poem

A rabbit hops with code anew,
Seeding admins, test users too!
Errors now return, not shout,
The main path takes a fresher route.
With every leap, the system grows—
In tidy rows, the user flows!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15c9b84 and 43c8860.

📒 Files selected for processing (3)
  • main.go (1 hunks)
  • util/seed/superadmin.go (3 hunks)
  • util/seed/user.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
main.go (1)
util/seed/user.go (1)
  • Insert (17-27)
util/seed/user.go (3)
config/config.go (1)
  • AppConfig (14-14)
service/userCrudService.go (1)
  • NewUserCrudService (43-53)
model/user.go (2)
  • User (49-69)
  • RoleOsoba (18-18)
🔇 Additional comments (4)
main.go (1)

32-32: LGTM! Clean transition to the new seeding approach.

The function call correctly updates to use the new centralized seeding mechanism.

util/seed/user.go (1)

42-45: Proper error propagation.

Good error handling - the function correctly propagates errors from the user creation service.

util/seed/superadmin.go (2)

22-22: Excellent refactoring of function signature.

Changing from void return to error return enables proper error propagation and removes the need for panics during bootstrap failures.


32-33: Improved error handling throughout the function.

All error scenarios now properly return errors instead of panicking or silently returning. This provides much better error propagation and allows calling code to handle failures appropriately.

The explicit return nil on success paths ensures consistent return behavior.

Also applies to: 37-37, 44-44, 47-47, 61-61, 66-66, 69-69

Comment thread util/seed/user.go
Comment on lines +13 to +15
const (
_TEST_PASSWORD = "Pa$$w0rd"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider using a more secure approach for test passwords.

While this constant works for testing, consider if the password should be configurable via environment variables for different test environments.

🤖 Prompt for AI Agents
In util/seed/user.go around lines 13 to 15, the test password is hardcoded as a
constant, which is not flexible or secure for different test environments.
Modify the code to read the test password from an environment variable with a
fallback to a default value. This allows configuring the password externally and
improves security and flexibility during testing.

Comment thread util/seed/user.go
Comment on lines +17 to +27
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().DPanicf("Failed to create superadmin, err = %+v\n", err)
}

if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().DPanicf("Failed to create user, err = %+v\n", err)
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Inconsistent error handling behavior between environments.

Using DPanicf means the application will panic in development but only log in production. This creates inconsistent behavior across environments.

Consider using consistent error handling:

-		zap.S().DPanicf("Failed to create superadmin, err = %+v\n", err)
+		zap.S().Errorf("Failed to create superadmin, err = %+v\n", err)
+		return
-			zap.S().DPanicf("Failed to create user, err = %+v\n", err)
+			zap.S().Errorf("Failed to create user, err = %+v\n", err)
+			return
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().DPanicf("Failed to create superadmin, err = %+v\n", err)
}
if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().DPanicf("Failed to create user, err = %+v\n", err)
}
}
}
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().Errorf("Failed to create superadmin, err = %+v\n", err)
return
}
if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().Errorf("Failed to create user, err = %+v\n", err)
return
}
}
}
🤖 Prompt for AI Agents
In util/seed/user.go around lines 17 to 27, the use of zap.S().DPanicf for error
logging causes inconsistent behavior across environments because it panics in
development but only logs in production. To fix this, replace DPanicf with a
consistent error handling approach such as using zap.S().Errorf or returning the
error to be handled uniformly, ensuring the application behavior is consistent
regardless of environment.

Comment thread util/seed/user.go
Comment on lines +32 to +40
newUser := model.User{
FirstName: "Test",
LastName: "Osoba",
Email: "osoba@test.hr",
OIB: "72352576276",
Role: model.RoleOsoba,
BirthDate: time.Now().AddDate(-20, 0, 0),
Uuid: uuid.New(),
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify OIB validity and add missing required field.

Two issues with the user creation:

  1. The OIB "72352576276" should be validated as Croatian OIBs use a specific checksum algorithm
  2. The Residence field appears to be required (not null) in the model but is missing here

Please verify that this OIB is valid using the Croatian OIB checksum algorithm, and add the missing Residence field:


🏁 Script executed:

#!/bin/bash
# Check if the Residence field is indeed required in the User model
ast-grep --pattern $'type User struct {
  $$$
  Residence $_ `gorm:"$$$not null$$$"`
  $$$
}'

Length of output: 94


🏁 Script executed:

#!/bin/bash
# Search for User struct definition and Residence field
rg -n "type User struct" -A20
rg -n "Residence" -A2

# Verify Croatian OIB checksum validity
python3 - << 'EOF'
def validate_oib(oib):
    if len(oib) != 11 or not oib.isdigit():
        return False
    factor = 10
    for d in oib[:10]:
        factor = (factor + int(d)) % 10
        if factor == 0:
            factor = 10
        factor = (factor * 2) % 11
    check = 11 - factor
    if check == 10:
        check = 0
    return check == int(oib[-1])

oib = "72352576276"
result = validate_oib(oib)
print(f"OIB {oib} is", "valid." if result else "invalid.")
EOF

Length of output: 9784


Add missing Residence to seeded User

The Croatian OIB “72352576276” is valid per the checksum algorithm, so no change is needed there. However, in util/seed/user.go the newUser initializer omits the required Residence field (defined as not null in model/User), which will cause a constraint violation at runtime.

• File util/seed/user.go, around the newUser := model.User{…} block: include a Residence: "<some test address>", entry.
• Ensure the chosen default or dummy value fits the expected format (e.g. a non-empty string ≤255 chars).

🤖 Prompt for AI Agents
In util/seed/user.go around lines 32 to 40, the user creation code is missing
the required Residence field, which is defined as not null in the User model and
will cause a runtime constraint violation. Add a Residence field with a suitable
non-empty string value (e.g., a test address) to the newUser struct
initialization. The OIB value is valid and does not require changes.

@Tiitmouse
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (2)
util/seed/user.go (2)

15-17: Consider using a more secure approach for test passwords.

While this constant works for testing, consider if the password should be configurable via environment variables for different test environments.


40-48: ⚠️ Potential issue

Add missing Residence field to prevent constraint violation.

The newUser initialization is missing the required Residence field (defined as not null in the User model), which will cause a runtime constraint violation.

Add the missing field:

 newUser := model.User{
 	FirstName: "Test",
 	LastName:  "Osoba",
 	Email:     "osoba@test.hr",
 	OIB:       "72352576276",
+	Residence: "Test Address 123, Zagreb",
 	Role:      model.RoleOsoba,
 	BirthDate: time.Now().AddDate(-20, 0, 0),
 	Uuid:      uuid.New(),
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43c8860 and dec1b78.

📒 Files selected for processing (4)
  • service/loginService.go (1 hunks)
  • util/device/registerDevice.go (2 hunks)
  • util/seed/superadmin.go (3 hunks)
  • util/seed/user.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
service/loginService.go (1)
util/device/registerDevice.go (1)
  • NewDeviceManager (31-42)
util/device/registerDevice.go (1)
app/dig.go (1)
  • Invoke (48-52)
util/seed/user.go (5)
model/user.go (2)
  • User (49-69)
  • RoleOsoba (18-18)
config/config.go (1)
  • AppConfig (14-14)
service/userCrudService.go (1)
  • NewUserCrudService (43-53)
app/dig.go (1)
  • Invoke (48-52)
model/mobile.go (1)
  • Mobile (8-15)
🪛 Gitleaks (8.26.0)
util/seed/user.go

71-71: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

(jwt)

🔇 Additional comments (4)
service/loginService.go (1)

40-40: LGTM! Dependency injection refactoring looks good.

The change aligns well with the refactored NewDeviceManager() constructor that now uses dependency injection internally. This simplifies the instantiation and centralizes dependency management.

util/device/registerDevice.go (1)

31-42: LGTM! Dependency injection refactoring improves architecture.

The refactoring from explicit parameter passing to dependency injection using app.Invoke is well-implemented. This approach:

  • Centralizes dependency management
  • Simplifies constructor calls across the codebase
  • Maintains consistency with other service constructors

The implementation correctly injects the required dependencies and returns the initialized DeviceManager.

util/seed/superadmin.go (2)

22-22: LGTM! Function visibility change is appropriate.

Making the function private (createSuperAdmin) makes sense since it's now called through the centralized Insert() function in util/seed/user.go.


32-70: Excellent error handling refactoring!

The change from panic-based error handling to returning errors is a significant improvement:

  • Allows callers to handle errors gracefully
  • Provides better control flow
  • Maintains consistent error propagation patterns

The explicit return nil on success and proper error returns throughout make the function more robust and testable.

Comment thread util/seed/user.go
})

deviceInfo := model.Mobile{
Uuid: uuid.MustParse("495201e5-dc8c-4f3f-af41-66fcdd5e6778"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use dynamic UUID generation instead of hardcoded value.

Using a hardcoded UUID can cause conflicts if the seed is run multiple times or in different environments.

Replace the hardcoded UUID with dynamic generation:

-	Uuid:             uuid.MustParse("495201e5-dc8c-4f3f-af41-66fcdd5e6778"),
+	Uuid:             uuid.New(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Uuid: uuid.MustParse("495201e5-dc8c-4f3f-af41-66fcdd5e6778"),
Uuid: uuid.New(),
🤖 Prompt for AI Agents
In util/seed/user.go at line 67, replace the hardcoded UUID value with a
dynamically generated UUID using uuid.New() or an equivalent function to avoid
conflicts when the seed is run multiple times or in different environments.

Comment thread util/seed/user.go
Comment on lines +22 to +35
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().Panicf("Failed to create superadmin, err = %+v\n", err)
}

if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().Panicf("Failed to create user, err = %+v\n", err)
}
if err := createDevice(); err != nil {

}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incomplete error handling for device creation.

The error handling for createDevice() is incomplete - the error is not being handled or logged.

Apply this diff to fix the error handling:

 	if err := createDevice(); err != nil {
-
+		zap.S().Panicf("Failed to create device, err = %+v\n", err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().Panicf("Failed to create superadmin, err = %+v\n", err)
}
if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().Panicf("Failed to create user, err = %+v\n", err)
}
if err := createDevice(); err != nil {
}
}
}
func Insert() {
if err := createSuperAdmin(); err != nil {
zap.S().Panicf("Failed to create superadmin, err = %+v\n", err)
}
if config.AppConfig.Env == config.Test {
if err := createUser(); err != nil {
zap.S().Panicf("Failed to create user, err = %+v\n", err)
}
if err := createDevice(); err != nil {
zap.S().Panicf("Failed to create device, err = %+v\n", err)
}
}
}
🤖 Prompt for AI Agents
In util/seed/user.go around lines 22 to 35, the error returned by createDevice()
is not handled or logged. Update the code to check the error from createDevice()
and log it using zap.S().Panicf with a descriptive message, similar to the error
handling for createSuperAdmin() and createUser().

Comment thread util/seed/user.go
UserId: osoba.ID,
CreatorId: osoba.ID,
RegisteredDevice: "Google Pixel 9 (Android)",
ActivationToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJ1dWlkIjoiNDk1MjAxZTUtZGM4Yy00ZjNmLWFmNDEtNjZmY2RkNWU2Nzc4Iiwicm9sZSI6Ik9TT0JBIiwiZXhwIjoxNzA5ODc2NDAwLCJpYXQiOjE3MDcyODQ0MDB9.TEST_SIGNATURE",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace hardcoded JWT token with dynamic generation.

The hardcoded JWT token poses security risks and will likely be expired. For test data, either generate a valid token dynamically or use a placeholder that doesn't contain sensitive information.

Consider generating a proper activation token or using a test placeholder:

-	ActivationToken:  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJ1dWlkIjoiNDk1MjAxZTUtZGM4Yy00ZjNmLWFmNDEtNjZmY2RkNWU2Nzc4Iiwicm9sZSI6Ik9TT0JBIiwiZXhwIjoxNzA5ODc2NDAwLCJpYXQiOjE3MDcyODQ0MDB9.TEST_SIGNATURE",
+	ActivationToken:  "test-activation-token-" + uuid.New().String(),

Alternatively, if you need a proper JWT token, generate it using the same mechanism as the application.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ActivationToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJ1dWlkIjoiNDk1MjAxZTUtZGM4Yy00ZjNmLWFmNDEtNjZmY2RkNWU2Nzc4Iiwicm9sZSI6Ik9TT0JBIiwiZXhwIjoxNzA5ODc2NDAwLCJpYXQiOjE3MDcyODQ0MDB9.TEST_SIGNATURE",
- ActivationToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJ1dWlkIjoiNDk1MjAxZTUtZGM4Yy00ZjNmLWFmNDEtNjZmY2RkNWU2Nzc4Iiwicm9sZSI6Ik9TT0JBIiwiZXhwIjoxNzA5ODc2NDAwLCJpYXQiOjE3MDcyODQ0MDB9.TEST_SIGNATURE",
+ ActivationToken: "test-activation-token-" + uuid.New().String(),
🧰 Tools
🪛 Gitleaks (8.26.0)

71-71: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

(jwt)

🤖 Prompt for AI Agents
In util/seed/user.go at line 71, replace the hardcoded JWT token string with a
dynamically generated token or a non-sensitive placeholder. To fix this,
implement token generation using the application's JWT creation method to
produce a valid activation token at runtime, or substitute the hardcoded token
with a clearly marked test placeholder that does not contain real or sensitive
data.

Comment thread util/seed/user.go
Comment on lines +60 to +65
func createDevice() error {
var db *gorm.DB
app.Invoke(func(database *gorm.DB) {
db = database
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider adding error handling for dependency injection.

The app.Invoke call should handle potential injection failures more gracefully.

Consider adding error handling:

 func createDevice() error {
 	var db *gorm.DB
-	app.Invoke(func(database *gorm.DB) {
-		db = database
-	})
+	var injectionErr error
+	app.Invoke(func(database *gorm.DB) {
+		if database == nil {
+			injectionErr = errors.New("database injection failed")
+			return
+		}
+		db = database
+	})
+	if injectionErr != nil {
+		return injectionErr
+	}

However, based on the current app.Invoke implementation that panics on failure, this may not be necessary unless you want to change the error handling strategy.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In util/seed/user.go around lines 60 to 65, the app.Invoke call for dependency
injection currently does not handle errors explicitly. To improve robustness,
modify the code to capture any error returned by app.Invoke and handle it
gracefully, such as returning the error from createDevice or logging it. This
involves changing the app.Invoke call to check for an error and acting
accordingly, instead of assuming it always succeeds or panics.

@Tiitmouse Tiitmouse merged commit 8372cea into main Jun 2, 2025
2 checks passed
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