Skip to content

Conversation

@robert-chiniquy
Copy link
Contributor

@robert-chiniquy robert-chiniquy commented Nov 25, 2025

Release Notes

  • Form fields are now supported for grant task creation both interactively and non-interactively (JSON)

Summary by CodeRabbit

  • New Features

    • Add ability to update request data for existing tasks.
    • Allow attaching additional request data when creating tasks.
  • Chores

    • Introduce logging infrastructure with configurable log levels and a global logger.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • cmd/cone/form_fields.go is excluded by none and included by none
  • cmd/cone/get_drop_task.go is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

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

Walkthrough

CreateGrantTask gains an optional requestData parameter and a new UpdateTaskRequestData method is added to update task request payloads. A new pkg/logging package provides a singleton Zap-based logger with levels, idempotent Init, Get(), and convenience helpers.

Changes

Cohort / File(s) Change Summary
Task API: interface & client
pkg/client/client.go, pkg/client/task.go
CreateGrantTask(...) signature extended to accept requestData map[string]any; added UpdateTaskRequestData(ctx context.Context, taskID string, requestData map[string]any) (*shared.TaskServiceActionResponse, error) to the client interface and implemented it. CreateGrantTask attaches non-empty requestData to grant requests; UpdateTaskRequestData builds and sends an UpdateRequestDataRequest and handles SDK/HTTP response mapping.
Logging package
pkg/logging/logging.go
New package introducing type Level string and constants (LevelDebug, LevelInfo, LevelWarn, LevelError); Init(level Level) using sync.Once; Get() *zap.SugaredLogger returning a no-op logger if uninitialized; newLogger maps levels to zapcore levels and configures a console encoder; convenience helpers Debug/Debugf/Info/Infof/Warn/Warnf/Error/Errorf.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Verify all callers of CreateGrantTask updated to the new signature and compile.
  • Review UpdateTaskRequestData request payload construction, error handling, and mapping to shared.TaskServiceActionResponse.
  • Confirm HTTP/raw SDK response handling and status-code-to-error behavior.
  • Check thread-safety and idempotency of logging Init/Get, and fallback no-op logger behavior.
  • Ensure imports, module builds, and tests compile with the new package.

Poem

🐰 I hopped through code with careful paws and cheer,
Pocketed requestData so tasks draw near,
A zap of logger hums, steady, clear, and bright,
I binky, stamp, and file—then vanish into night. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add form field input on task creation (if present)' accurately describes the main change: adding support for form fields (requestData) to task creation via the new requestData parameter in CreateGrantTask and the new UpdateTaskRequestData method.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

  - Added UpdateTaskRequestData client method to update task after collection

  - Change --form-data flag from comma-separated to JSON format
    Properly handles values containing commas or special characters

  - Improve required field validation using IgnoreEmpty and MinLen rules

  - Fix Int64FieldValidator to be consistent with StringFieldValidator
    Default values now passed as initial values, not returned from IsValid

  - Add context cancellation checks to collectBoolField/collectStringSliceField

  - Add logging package (pkg/logging) with zap and --log-level flag
    Supports debug, info, warn, error levels; silent by default
…enter 1 value at a time for form fields which take a list
@robert-chiniquy robert-chiniquy marked this pull request as ready for review December 12, 2025 18:32
Copy link

@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

🧹 Nitpick comments (2)
pkg/client/task.go (1)

23-47: requestData propagation looks correct; consider normalizing empty maps at the API boundary.

You already guard nil/empty for create; that’s good. For consistency with UpdateTaskRequestData, consider documenting whether empty means “no change” vs “clear”.

pkg/logging/logging.go (1)

43-78: Zap config: consider disabling color levels when stderr isn’t a TTY (CI/log aggregation).

zapcore.CapitalColorLevelEncoder can pollute non-interactive logs; a non-color encoder (or env/TTY check) is often friendlier for downstream parsing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c66f2d and 86c4340.

⛔ Files ignored due to path filters (4)
  • cmd/cone/flags.go is excluded by none and included by none
  • cmd/cone/form_fields.go is excluded by none and included by none
  • cmd/cone/get_drop_task.go is excluded by none and included by none
  • cmd/cone/main.go is excluded by none and included by none
📒 Files selected for processing (3)
  • pkg/client/client.go (2 hunks)
  • pkg/client/task.go (3 hunks)
  • pkg/logging/logging.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/client/task.go (1)
pkg/client/error.go (1)
  • NewHTTPError (26-47)
🪛 GitHub Check: go-lint
pkg/logging/logging.go

[failure] 115-115:
Comment should end in a period (godot)


[failure] 110-110:
Comment should end in a period (godot)


[failure] 105-105:
Comment should end in a period (godot)


[failure] 100-100:
Comment should end in a period (godot)


[failure] 95-95:
Comment should end in a period (godot)


[failure] 90-90:
Comment should end in a period (godot)


[failure] 85-85:
Comment should end in a period (godot)


[failure] 80-80:
Comment should end in a period (godot)


[failure] 15-15:
Comment should end in a period (godot)

🔇 Additional comments (2)
pkg/client/client.go (2)

94-95: The new UpdateTaskRequestData interface method is properly implemented in the concrete client and does not break any existing code.

This codebase has no mocks or wrapper implementations of C1Client. The only implementation of the C1Client interface is the concrete client struct in pkg/client/client.go, which includes the complete implementation of UpdateTaskRequestData in pkg/client/task.go. No test doubles, mocks, or wrapper types exist that would need updating.

Likely an incorrect or invalid review comment.


70-80: Interface signature updated consistently: CreateGrantTask now accepts requestData parameter.

The C1Client interface (line 70-80) has been updated to include the requestData map[string]any parameter, and the implementation in pkg/client/task.go (line 23-33) matches this signature. No external call sites or separate implementations of this interface exist in the codebase that require updating.

Copy link
Contributor

@pquerna pquerna left a comment

Choose a reason for hiding this comment

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

LGTM baring lint errors

Copy link

@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: 0

♻️ Duplicate comments (1)
pkg/logging/logging.go (1)

10-41: Data race: unsynchronized read of logger in Get().

The sync.Once protects the write inside once.Do, but Get() reads logger without synchronization. If Init() and Get() are called concurrently from different goroutines, this is a data race under the Go memory model.

Additionally, line 38 allocates a new no-op logger on every call to Get() before initialization, which is wasteful.

Use atomic.Value or sync.RWMutex for thread-safe access:

 import (
-	"sync"
+	"sync/atomic"
 
 	"go.uber.org/zap"
 	"go.uber.org/zap/zapcore"
 )
 
 var (
-	logger *zap.SugaredLogger
-	once   sync.Once
+	logger atomic.Pointer[zap.SugaredLogger]
+	once   sync.Once
+	nop    = zap.NewNop().Sugar()
 )
 func Init(level Level) {
 	once.Do(func() {
-		logger = newLogger(level)
+		logger.Store(newLogger(level))
 	})
 }
 
 func Get() *zap.SugaredLogger {
-	if logger == nil {
-		// Return a no-op logger if not initialized
-		return zap.NewNop().Sugar()
-	}
-	return logger
+	if l := logger.Load(); l != nil {
+		return l
+	}
+	return nop
 }
🧹 Nitpick comments (2)
pkg/client/task.go (2)

45-47: Simplify: omit redundant nil check.

The nil check is unnecessary since len(nil) returns 0 for maps in Go. The static analyzer flagged this (S1009).

-	if requestData != nil && len(requestData) > 0 {
+	if len(requestData) > 0 {
 		req.RequestData = requestData
 	}

166-183: Simplify nil check and consider early return for empty data.

Two observations:

  1. The nil check at line 168 is redundant (S1009) since len(nil) returns 0.

  2. Unlike CreateGrantTask where requestData is optional, calling UpdateTaskRequestData with empty data still makes an API call with an empty Data field. Consider returning early to avoid unnecessary network calls.

 func (c *client) UpdateTaskRequestData(ctx context.Context, taskID string, requestData map[string]any) (*shared.TaskServiceActionResponse, error) {
+	if len(requestData) == 0 {
+		return nil, fmt.Errorf("requestData must be non-empty")
+	}
 	req := shared.TaskActionsServiceUpdateRequestDataRequest{}
-	if requestData != nil && len(requestData) > 0 {
-		req.Data = requestData
-	}
+	req.Data = requestData
 	resp, err := c.sdk.TaskActions.UpdateRequestData(ctx, operations.C1APITaskV1TaskActionsServiceUpdateRequestDataRequest{
-		TaskActionsServiceUpdateRequestDataRequest: &req,
-		TaskID:                                     taskID,
+		TaskActionsServiceUpdateRequestDataRequest: &req,
+		TaskID: taskID,
 	})

Note: Add "fmt" to imports if adopting the error return.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86c4340 and 5b1d040.

📒 Files selected for processing (2)
  • pkg/client/task.go (3 hunks)
  • pkg/logging/logging.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: go-lint
pkg/client/task.go

[failure] 45-45:
S1009: should omit nil check; len() for nil maps is defined as zero (gosimple)


[failure] 168-168:
S1009: should omit nil check; len() for nil maps is defined as zero (gosimple)


[failure] 173-173:
File is not properly formatted (goimports)

🔇 Additional comments (2)
pkg/logging/logging.go (2)

43-78: LGTM!

The newLogger function correctly maps log levels, configures console encoding with ISO8601 timestamps, and falls back gracefully to a no-op logger on build failure.


80-118: LGTM!

The convenience helper functions correctly delegate to Get(), ensuring consistent logger access throughout the codebase.

@robert-chiniquy robert-chiniquy merged commit 34d69cd into main Dec 12, 2025
3 checks passed
@robert-chiniquy robert-chiniquy deleted the rch/new-grant/custom-form-fields branch December 12, 2025 19:03
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.

3 participants