Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0eecc44
sca-scan.yml
aravindbuilt Jan 20, 2025
0670129
jira.yml
aravindbuilt Jan 20, 2025
372ab3d
sast-scan.yml
aravindbuilt Jan 20, 2025
d14789a
codeql-analysis.yml
aravindbuilt Jan 20, 2025
1048535
Updated codeowners
aravindbuilt Jan 20, 2025
9c5ad9c
policy-scan.yml
aravindbuilt Apr 16, 2025
2446d41
issues-jira.yml
aravindbuilt Apr 16, 2025
276acd1
Delete jira.yml
aravindbuilt Apr 16, 2025
a6ac380
Delete sast-scan.yml
aravindbuilt Apr 16, 2025
4c6dfea
codeql-analysis.yml
aravindbuilt Apr 16, 2025
1a9d128
Updated codeowners
aravindbuilt Apr 16, 2025
f6e4b5f
policy-scan.yml
aravindbuilt Apr 23, 2025
da17c18
policy-scan.yml
aravindbuilt May 5, 2025
8cea81e
issues-jira.yml
aravindbuilt May 5, 2025
4ff653d
secrets-scan.yml
aravindbuilt May 5, 2025
baae9ed
Updated codeowners
aravindbuilt May 5, 2025
a266f05
talismanrc file updated
aravindbuilt May 5, 2025
64709a0
Delete secrets-scan.yml
aravindbuilt Sep 8, 2025
9036111
Updated codeowners
aravindbuilt Sep 8, 2025
5094f52
Update dependencies and improve error handling
reeshika-h Dec 15, 2025
3aa43de
Merge pull request #43 from contentstack/development
sunil-lakshman Jan 2, 2026
64189a8
Merge pull request #45 from contentstack/master
sunil-lakshman Jan 2, 2026
22af676
Merge branch 'development' into fix/DX-3746-improve-error-msgs
reeshika-h Jan 2, 2026
7a28d41
Merge pull request #47 from contentstack/development
harshithad0703 Jan 2, 2026
bfeae4d
Merge pull request #44 from contentstack/staging
harshithad0703 Jan 5, 2026
3ba84f8
Merge branch 'master' into fix/DX-3746-improve-error-msgs
reeshika-h Jan 7, 2026
6153ba6
Update version to 0.8.2 and enhance error messages in CHANGELOG
reeshika-h Jan 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/issues-jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Create Jira Ticket for Github Issue

on:
issues:
types: [opened]

jobs:
issue-jira:
runs-on: ubuntu-latest
steps:

- name: Login to Jira
uses: atlassian/gajira-login@master
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Create Jira Issue
id: create_jira
uses: atlassian/gajira-create@master
with:
project: ${{ secrets.JIRA_PROJECT }}
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }}
description: |
*GitHub Issue:* ${{ github.event.issue.html_url }}

*Description:*
${{ github.event.issue.body }}
fields: "${{ secrets.ISSUES_JIRA_FIELDS }}"
33 changes: 0 additions & 33 deletions .github/workflows/jira.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/policy-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Checks the security policy and configurations
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
security-policy:
if: github.event.repository.visibility == 'public'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@master
- name: Checks for SECURITY.md policy file
run: |
if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi
security-license:
if: github.event.repository.visibility == 'public'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@master
- name: Checks for License file
run: |
expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt")
license_file_found=false
current_year=$(date +"%Y")

for license_file in "${expected_license_files[@]}"; do
if [ -f "$license_file" ]; then
license_file_found=true
# check the license file for the current year, if not exists, exit with error
if ! grep -q "$current_year" "$license_file"; then
echo "License file $license_file does not contain the current year."
exit 2
fi
break
fi
done

if [ "$license_file_found" = false ]; then
echo "No license file found. Please add a license file to the repository."
exit 1
fi
11 changes: 0 additions & 11 deletions .github/workflows/sast-scan.yml

This file was deleted.

9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
## CHANGELOG

## Version 0.8.0
## Version 0.8.2
### Date: 12th-January-2026
### Improved error messages
-

------------------------------------------------

## Version 0.8.1
### Date: 05th-January-2026
### Security Bug
- Fixed snyk security issues and updated license year
Expand Down
12 changes: 11 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
* @contentstack/security-admin
* @contentstack/devex-pr-reviewers

.github/workflows/sca-scan.yml @contentstack/security-admin

.github/workflows/codeql-anaylsis.yml @contentstack/security-admin

**/.snyk @contentstack/security-admin

.github/workflows/policy-scan.yml @contentstack/security-admin

.github/workflows/issues-jira.yml @contentstack/security-admin
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GEM
simplecov_json_formatter (0.1.4)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.1.1)
webmock (3.11.3)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand All @@ -76,6 +77,7 @@ GEM

PLATFORMS
arm64-darwin-22
arm64-darwin-24

DEPENDENCIES
contentstack!
Expand Down
6 changes: 3 additions & 3 deletions lib/contentstack/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def self.fetch_retry(path, query=nil, count=0)
sleep(retryDelay_in_seconds.to_i) #sleep method requires time in seconds as parameter
response = fetch_retry(path, query, (count + 1))
else
raise Contentstack::Error.new(response) #Retry Limit exceeded
raise Contentstack::Error.new(Contentstack::ErrorMessages.request_failed(response)) #Retry Limit exceeded
end
else
to_render_content(response)
Expand Down Expand Up @@ -125,7 +125,7 @@ def self.send_request(path, q=nil)
error_response = JSON.parse(response.string)
error_status = {"status_code" => response.status[0], "status_message" => response.status[1]}
error = error_response.merge(error_status)
raise Contentstack::Error.new(error.to_s)
raise Contentstack::Error.new(Contentstack::ErrorMessages.request_error(error))
end
end

Expand Down Expand Up @@ -165,7 +165,7 @@ def self.send_preview_request(path, q=nil)
error_response = JSON.parse(response.string)
error_status = {"status_code" => response.status[0], "status_message" => response.status[1]}
error = error_response.merge(error_status)
raise Contentstack::Error.new(error.to_s)
raise Contentstack::Error.new(Contentstack::ErrorMessages.request_error(error))
end
end

Expand Down
16 changes: 8 additions & 8 deletions lib/contentstack/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class Client
attr_reader :region, :host
# Initialize "Contentstack" Client instance
def initialize(api_key, delivery_token, environment, options={})
raise Contentstack::Error.new("Api Key is not valid") if api_key.class != String
raise Contentstack::Error.new("Api Key Field Should not be Empty") if api_key.empty?
raise Contentstack::Error.new("Delivery Token is not valid") if delivery_token.class != String
raise Contentstack::Error.new("Delivery Token Field Should not be Empty") if delivery_token.empty?
raise Contentstack::Error.new("Envirnoment Field is not valid") if environment.class != String
raise Contentstack::Error.new("Envirnoment Field Should not be Empty") if environment.empty?
raise Contentstack::Error.new(Contentstack::ErrorMessages::API_KEY_INVALID) if api_key.class != String
raise Contentstack::Error.new(Contentstack::ErrorMessages::API_KEY_REQUIRED) if api_key.empty?
raise Contentstack::Error.new(Contentstack::ErrorMessages::DELIVERY_TOKEN_INVALID) if delivery_token.class != String
raise Contentstack::Error.new(Contentstack::ErrorMessages::DELIVERY_TOKEN_REQUIRED) if delivery_token.empty?
raise Contentstack::Error.new(Contentstack::ErrorMessages::ENVIRONMENT_INVALID) if environment.class != String
raise Contentstack::Error.new(Contentstack::ErrorMessages::ENVIRONMENT_REQUIRED) if environment.empty?
@region = options[:region].nil? ? Contentstack::Region::US : options[:region]
# @host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host] #removed for not supporting custom host with regions
@host = get_host_by_region(@region, options) # Added new method for custom host support with different regions
Expand All @@ -32,8 +32,8 @@ def initialize(api_key, delivery_token, environment, options={})
"retryLimit"=> @retryLimit,
"errorRetry" => @errorRetry
}
raise Contentstack::Error.new("Proxy URL Should not be Empty") if @proxy_details.present? && @proxy_details[:url].empty?
raise Contentstack::Error.new("Proxy Port Should not be Empty") if @proxy_details.present? && @proxy_details[:port].empty?
raise Contentstack::Error.new(Contentstack::ErrorMessages::PROXY_URL_REQUIRED) if @proxy_details.present? && @proxy_details[:url].empty?
raise Contentstack::Error.new(Contentstack::ErrorMessages::PROXY_PORT_REQUIRED) if @proxy_details.present? && @proxy_details[:port].empty?
API.init_api(api_key, delivery_token, environment, @host, @branch, @live_preview, @proxy_details, retry_options)
end

Expand Down
20 changes: 20 additions & 0 deletions lib/contentstack/error.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
module Contentstack
# Centralized error messages for the SDK
module ErrorMessages
API_KEY_INVALID = "API Key is invalid. Provide a valid API Key and try again."
API_KEY_REQUIRED = "API Key is required. Provide a valid API Key and try again."
DELIVERY_TOKEN_INVALID = "Delivery Token is invalid. Provide a valid Delivery Token and try again."
DELIVERY_TOKEN_REQUIRED = "Delivery Token is required. Provide a valid Delivery Token and try again."
ENVIRONMENT_INVALID = "Environment is invalid. Provide a valid Environment and try again."
ENVIRONMENT_REQUIRED = "Environment is required. Provide a valid Environment and try again."
PROXY_URL_REQUIRED = "Proxy URL is required. Provide a valid Proxy URL and try again."
PROXY_PORT_REQUIRED = "Proxy Port is required. Provide a valid Proxy Port and try again."

def self.request_failed(response)
"The request could not be completed due to #{response}. Review the details and try again."
end

def self.request_error(error)
"The request encountered an issue due to #{error}. Review the details and try again."
end
end

class Error < StandardError
def initialize(msg="Something Went Wrong.")
super
Expand Down
2 changes: 1 addition & 1 deletion lib/contentstack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Contentstack
VERSION = "0.8.1"
VERSION = "0.8.2"
end
Loading