CON-1842 Add a --nojob option for the upload command#91
Conversation
Summary of ChangesHello @az-smartling, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a --nojob option for the upload command, enabling file uploads without an associated job. The implementation adds a new code path for direct file uploads. While the feature is a good addition, I've identified a critical bug in the new logic related to directive handling that needs to be addressed. Additionally, there are opportunities to improve code maintainability by refactoring duplicated logic and renaming a function for better clarity. Please see my detailed comments below.
| for _, directive := range params.Directives { | ||
| spec := strings.SplitN(directive, "=", 2) | ||
| if len(spec) != 2 { | ||
| return clierror.NewError( | ||
| fmt.Errorf( | ||
| "invalid directive specification: %q", | ||
| directive, | ||
| ), | ||
|
|
||
| `Should be in the form of <name>=<value>.`, | ||
| ) | ||
| } | ||
|
|
||
| if request.Smartling.Directives == nil { | ||
| request.Smartling.Directives = map[string]string{} | ||
| } | ||
|
|
||
| request.Smartling.Directives[spec[0]] = spec[1] | ||
| } |
There was a problem hiding this comment.
There is a bug in how command-line directives are processed. The params.Directives field is a map[string]string that has already been parsed from the command-line arguments. This loop incorrectly iterates over the map's values and tries to parse them again as key=value strings. This will cause incorrect behavior when using the --directive flag with --nojob.
The loop should iterate over the key-value pairs of the map and merge them into request.Smartling.Directives.
I suggest replacing this block with:
if len(params.Directives) > 0 {
if request.Smartling.Directives == nil {
request.Smartling.Directives = make(map[string]string)
}
for key, value := range params.Directives {
request.Smartling.Directives[key] = value
}
}| // Validate checks that the PushParams are valid | ||
| func (p PushParams) Validate() error { | ||
| if p.JobIDOrName != "" && p.NoJob { | ||
| return ErrInvalidParamCombination([]string{"job", "nojob"}) |
There was a problem hiding this comment.
There are more conflicting params. Pls check the jira. You can't specify a locale or autoauthorize.
Co-authored-by: Dmitry Studynsky <dimitrystd@users.noreply.github.com>
…job_option_for_upload
# Conflicts: # go.sum # services/files/run_push.go
Used old file push for
--nojob. Fixed problems in it raised by gemini-code-assist.Smartling/api-sdk-go#20