Skip to content

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

Merged
az-smartling merged 2 commits into
masterfrom
nojob_option_for_upload
Nov 21, 2025
Merged

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

Conversation

@az-smartling

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

Copy link
Copy Markdown
Contributor

@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 introduces the foundational components for uploading files to the Smartling API. It extends the existing API client with a new UploadFile method and provides the underlying implementation to prepare and send file data, along with associated metadata, to the Smartling platform. This enhancement enables programmatic file submission, which is a critical step for integrating with translation workflows.

Highlights

  • API Extension: The APIClient interface now includes a new UploadFile method, expanding the client's capabilities to support file uploads.
  • File Upload Implementation: New client-side logic has been added to handle the actual file upload process, including constructing the necessary multipart form data for API submission.
  • Request Struct Definition: A dedicated FileUploadRequest struct has been introduced to encapsulate all parameters required for a file upload, such as file content, type, and authorization settings.
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 adds the functionality to upload files to the Smartling API by introducing an UploadFile method on the API client. The changes are well-structured, following the existing patterns in the codebase. I've identified one area for improvement in the new file_upload_request.go file concerning repetitive error handling, and I've provided a suggestion to make the code more concise and maintainable. Overall, the implementation looks correct and is a good addition.

Comment thread helpers/sm_file/file_upload_request.go Outdated
Comment on lines +53 to +102
_, err = writer.Write(r.File)
if err != nil {
return nil, err
}

err = form.Writer.WriteField("fileType", string(r.FileType))
if err != nil {
return nil, err
}

if r.Authorize {
err = form.Writer.WriteField("authorize", "true")
if err != nil {
return nil, err
}
}

for _, locale := range r.LocalesToAuthorize {
err = form.Writer.WriteField("localeIdsToAuthorize[]", locale)
if err != nil {
return nil, err
}
}

if r.Smartling.Namespace != "" {
err = form.Writer.WriteField(
"smartling.namespace",
r.Smartling.Namespace,
)
if err != nil {
return nil, err
}
}

if r.Smartling.FileCharset != "" {
err = form.Writer.WriteField(
"smartling.file_charset",
r.Smartling.FileCharset,
)
if err != nil {
return nil, err
}
}

for directive, value := range r.Smartling.Directives {
err = form.Writer.WriteField("smartling."+directive, value)
if err != nil {
return nil, err
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error handling in this function is quite repetitive. While correct, it can be made more concise and maintainable by combining the assignment and check in a single if statement. This is a common Go idiom that improves readability.

	if _, err = writer.Write(r.File); err != nil {
		return nil, err
	}

	if err = form.Writer.WriteField("fileType", string(r.FileType)); err != nil {
		return nil, err
	}

	if r.Authorize {
		if err = form.Writer.WriteField("authorize", "true"); err != nil {
			return nil, err
		}
	}

	for _, locale := range r.LocalesToAuthorize {
		if err = form.Writer.WriteField("localeIdsToAuthorize[]", locale); err != nil {
			return nil, err
		}
	}

	if r.Smartling.Namespace != "" {
		if err = form.Writer.WriteField(
			"smartling.namespace",
			r.Smartling.Namespace,
		); err != nil {
			return nil, err
		}
	}

	if r.Smartling.FileCharset != "" {
		if err = form.Writer.WriteField(
			"smartling.file_charset",
			r.Smartling.FileCharset,
		); err != nil {
			return nil, err
		}
	}

	for directive, value := range r.Smartling.Directives {
		if err = form.Writer.WriteField("smartling."+directive, value); err != nil {
			return nil, err
		}
	}

@az-smartling az-smartling changed the title Add a --nojob option for the upload command CON-1842 Add a --nojob option for the upload command Nov 21, 2025
@az-smartling az-smartling merged commit c0e20a5 into master Nov 21, 2025
@az-smartling az-smartling deleted the nojob_option_for_upload branch November 21, 2025 17:24
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