Skip to content

Conversation

bytesizedroll
Copy link
Contributor

@bytesizedroll bytesizedroll commented Sep 30, 2025

Support Lazy Initialization for JIRA Client

Summary

Modified the JIRA client to support lazy initialization, allowing the client to be created without requiring credentials to be set upfront. Token validation now occurs when making actual API calls instead of during client construction.

Motivation

Previously, NewClientFromDomain() would fail immediately if the JIRA_TOKEN_{DOMAIN} environment variable was not set, causing issues when the client is initialized early (e.g., in init()) but never actually used.

Changes

  • NewClient(): Added domainName parameter and removed token validation check
  • NewClientFromDomain(): No longer fails when JIRA_TOKEN_{DOMAIN} is missing
  • GetIssue(): Added token validation before making API requests with helpful error messages:
    • With domain: "JIRA token is required but not set. Please set JIRA_TOKEN_{DOMAIN} environment variable"
    • Without domain: "JIRA token is required but not set"
  • Updated all tests to match new behavior

Testing

All existing tests pass with updated expectations for the new error messages.

@bytesizedroll bytesizedroll requested a review from a team as a code owner September 30, 2025 20:12
@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 20:12
Copy link

changeset-bot bot commented Sep 30, 2025

🦋 Changeset detected

Latest commit: 462974c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

👋 bytesizedroll, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements lazy loading for JIRA clients by allowing empty tokens during client initialization and deferring token validation until API calls are made.

  • Removes token validation from client constructors to allow lazy initialization
  • Adds token validation in the GetIssue method with helpful error messages
  • Updates test cases to reflect the new lazy loading behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
jira/client.go Implements lazy loading by removing token validation from constructors and adding it to GetIssue method
jira/client_test.go Updates tests to accommodate lazy initialization and adds new test cases for token validation
jira/converter_test.go Updates error message expectation for consistency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cl-sonarqube-production
Copy link

@graham-chainlink
Copy link
Collaborator

Previously, NewClientFromDomain() would fail immediately if the JIRA_TOKEN_{DOMAIN} environment variable was not set, causing issues when the client is initialized early (e.g., in init()) but never actually used.

@bytesizedroll i may be missing something, but user just need to setup the env var before starting up the app which is when the init is called, it seems weird to start the app then set the env var after that and then only call GetIssue?

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