Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into vvaradarjan/new_htt…
Browse files Browse the repository at this point in the history
…p_component
  • Loading branch information
ylecuyer committed May 1, 2024
2 parents 03ce756 + 64d17a8 commit 39210a5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.7, "3.0", 3.1, head]
ruby: [2.7, "3.0", 3.1, 3.2, 3.3, head]

steps:
- name: Checkout repository
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ New features:

Updated features:

* Add fbtrace_id, x-fb-rev, x-fb-debug to error messages and error class ([#668](https://github.com/arsduo/koala/pull/686))

Removed features:

Internal improvements:

* Require base64 for ruby 3.4 support ([#688](https://github.com/arsduo/koala/pull/688))

Testing improvements:

* Fix CI for ruby 3.4 ([#688](https://github.com/arsduo/koala/pull/688))
* Add latest rubies to CI ([#687](https://github.com/arsduo/koala/pull/687))

Others:

v3.5.0 (2023-08-23)
Expand Down
1 change: 1 addition & 0 deletions koala.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency("addressable")
gem.add_runtime_dependency("json", ">= 1.8")
gem.add_runtime_dependency("rexml")
gem.add_runtime_dependency("base64")
end
6 changes: 4 additions & 2 deletions lib/koala/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class APIError < ::Koala::KoalaError
:fb_error_user_msg,
:fb_error_user_title,
:fb_error_trace_id,
:fb_error_debug_trace_id,
:fb_error_debug,
:fb_error_rev,
:fb_buc_usage,
Expand Down Expand Up @@ -65,16 +66,17 @@ def initialize(http_status, response_body, error_info = nil)
self.fb_error_message = error_info["message"]
self.fb_error_user_msg = error_info["error_user_msg"]
self.fb_error_user_title = error_info["error_user_title"]
self.fb_error_trace_id = error_info["fbtrace_id"]

self.fb_error_trace_id = error_info["x-fb-trace-id"]
self.fb_error_debug_trace_id = error_info["x-fb-trace-id"]
self.fb_error_debug = error_info["x-fb-debug"]
self.fb_error_rev = error_info["x-fb-rev"]
self.fb_buc_usage = json_parse_for(error_info, "x-business-use-case-usage")
self.fb_ada_usage = json_parse_for(error_info, "x-ad-account-usage")
self.fb_app_usage = json_parse_for(error_info, "x-app-usage")

error_array = []
%w(type code error_subcode message error_user_title error_user_msg x-fb-trace-id).each do |key|
%w(type code error_subcode message error_user_title error_user_msg fbtrace_id x-fb-trace-id x-fb-debug x-fb-rev).each do |key|
error_array << "#{key}: #{error_info[key]}" if error_info[key]
end

Expand Down
6 changes: 4 additions & 2 deletions spec/cases/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
'error_subcode' => 'subcode',
'error_user_msg' => 'error user message',
'error_user_title' => 'error user title',
'x-fb-trace-id' => 'fb trace id',
'fbtrace_id' => 'fb trace id',
'x-fb-trace-id' => 'x-fb trace id',
'x-fb-debug' => 'fb debug token',
'x-fb-rev' => 'fb revision',
'x-business-use-case-usage' => BUC_USAGE_JSON,
Expand All @@ -52,6 +53,7 @@
:fb_error_user_msg => 'error user message',
:fb_error_user_title => 'error user title',
:fb_error_trace_id => 'fb trace id',
:fb_error_debug_trace_id => 'x-fb trace id',
:fb_error_debug => 'fb debug token',
:fb_error_rev => 'fb revision',
:fb_buc_usage => JSON.parse(BUC_USAGE_JSON),
Expand All @@ -64,7 +66,7 @@
end

it "sets the error message appropriately" do
expect(error.message).to eq("type: type, code: 1, error_subcode: subcode, message: message, error_user_title: error user title, error_user_msg: error user message, x-fb-trace-id: fb trace id [HTTP 400]")
expect(error.message).to eq("type: type, code: 1, error_subcode: subcode, message: message, error_user_title: error user title, error_user_msg: error user message, fbtrace_id: fb trace id, x-fb-trace-id: x-fb trace id, x-fb-debug: fb debug token, x-fb-rev: fb revision [HTTP 400]")
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/cases/graph_error_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ module Facebook
"error_subcode" => "FB error subcode",
"message" => "An error occurred!",
"error_user_msg" => "A user msg",
"error_user_title" => "usr title"
"error_user_title" => "usr title",
"fbtrace_id" => "fbtrace_id"
}
body.replace({"error" => error_data}.to_json)

expect(error.fb_error_trace_id).to eq(error_data["fbtrace_id"])
expect(error.fb_error_type).to eq(error_data["type"])
expect(error.fb_error_code).to eq(error_data["code"])
expect(error.fb_error_subcode).to eq(error_data["error_subcode"])
Expand All @@ -97,7 +99,7 @@ module Facebook
"x-ad-account-usage" => { 'c' => 3, 'd' => 4 }.to_json,
"x-app-usage" => { 'e' => 5, 'f' => 6 }.to_json
)
expect(error.fb_error_trace_id).to eq(headers["x-fb-trace-id"])
expect(error.fb_error_debug_trace_id).to eq(headers["x-fb-trace-id"])
expect(error.fb_error_debug).to eq(headers["x-fb-debug"])
expect(error.fb_error_rev).to eq(headers["x-fb-rev"])
expect(error.fb_buc_usage).to eq({ 'a' => 1, 'b' => 2 })
Expand Down

0 comments on commit 39210a5

Please sign in to comment.