Skip to content

CON-1842 Add a --nojob option for the upload command#91

Merged
az-smartling merged 11 commits into
masterfrom
nojob_option_for_upload
Nov 25, 2025
Merged

CON-1842 Add a --nojob option for the upload command#91
az-smartling merged 11 commits into
masterfrom
nojob_option_for_upload

Conversation

@az-smartling

@az-smartling az-smartling commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

Used old file push for --nojob. Fixed problems in it raised by gemini-code-assist.
Smartling/api-sdk-go#20

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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 upload command by introducing a --nojob option, which allows users to upload files directly to Smartling without the requirement of linking them to a translation job. This provides greater flexibility for managing content. The changes include robust parameter validation to prevent conflicting options and a clear separation of concerns in the upload logic to accommodate both job-based and job-less file processing.

Highlights

  • New --nojob option: Introduced a new --nojob flag for the upload command, enabling users to upload files to Smartling without associating them with a translation job.
  • Parameter Validation: Added validation logic to prevent the simultaneous use of the --job and --nojob options, ensuring correct command usage.
  • Refactored Upload Logic: The file upload mechanism has been refactored to support both job-associated and job-less uploads, with a new runPushWithoutJob function handling the latter.
  • Dependency Update: The github.com/Smartling/api-sdk-go dependency has been updated to a newer version, likely to support the new functionality and error handling.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +352 to +370
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]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

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
			}
		}

Comment thread services/files/errors.go
Comment thread services/files/run_push.go
Comment thread services/files/run_push.go
@dimitrystd dimitrystd changed the title Add a --nojob option for the upload command CON-1842 Add a --nojob option for the upload command Nov 19, 2025

@dimitrystd dimitrystd left a comment

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.

My brief review

Comment thread services/files/run_push.go Outdated
// Validate checks that the PushParams are valid
func (p PushParams) Validate() error {
if p.JobIDOrName != "" && p.NoJob {
return ErrInvalidParamCombination([]string{"job", "nojob"})

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.

There are more conflicting params. Pls check the jira. You can't specify a locale or autoauthorize.

Comment thread cmd/files/push/cmd_push.go Outdated
az-smartling and others added 4 commits November 19, 2025 11:14
Co-authored-by: Dmitry Studynsky <dimitrystd@users.noreply.github.com>
@az-smartling az-smartling merged commit 361f03e into master Nov 25, 2025
@az-smartling az-smartling deleted the nojob_option_for_upload branch November 25, 2025 14:11
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.

2 participants