-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REXML::ParseException: #<REXML::ParseException: Missing end tag for 'meta' ﴾got "head"﴿ #318
Comments
@akannur This error is coming from the ruby client so this issue may belong in this repo: https://github.com/recurly/recurly-client-ruby I'd need to see the code that is causing this to be sure, but it looks like it's maybe getting some kind of HTML page and expecting XML. Could you show the code which generated this error? |
namespace :batch_job_line_item do
desc "updates line item table"
task :update_line_item, [:run_name] => :environment do |_, args|
TAX_ADDON_CODE = "taxes:total_tax"
line_item = BatchJobLineItem.find_by_run_name(args[:run_name])
if line_item.present?
raise "Run Name already exists. Please create new Run Name."
else
line_item_log("Task started at: #{Time.now} with
run_name:#{args[:run_name]}")
File.open(File.join Rails.root, 'tmp', 'recurly_guids.txt') do |f|
f.each_line do |guid|
begin
line_item_log("Begins: batch job line item for guid:
#{guid.strip}")
user = User.find_by_guid(guid.strip)
if user.present?
subscriptions = user.recurly.try(:subscriptions)
if !subscriptions.present?
line_item_log("No subscriptions for user: #{guid.strip}")
create_line_item_error("NO SUBSCRIPTIONS", guid.strip,
args[:run_name])
else
taxable_attributes = format_taxable_attributes(user,
args[:run_name])
subscriptions.each do |subscription|
if (subscription.state == 'active' &&
!will_not_renew?(subscription)) || subscription.state == 'future'
line_item_log("--currently updating taxes for
subscription: #{subscription.uuid}")
update_tax(subscription, taxable_attributes)
end
end
end
else
line_item_log("No User for guid: #{guid.strip}")
create_line_item_error("NO USER", guid.strip, args[:run_name])
end
rescue Exception => e
line_item_log("Exception Raised: #{e.message} User: #{guid}")
end
end
end
line_item_log("Task ends at: #{Time.now} with
run_name:#{args[:run_name]}")
end
end
private
def create_line_item_error(status, guid, run_name)
BatchJobLineItem.create({status: status,
user_guid: guid,
run_name: run_name})
end
def format_taxable_attributes(user, run_name)
tax_attributes = user.recurly_billing_info.try(:deep_symbolize_keys)
{
state: tax_attributes[:state],
zip: tax_attributes[:zip],
user_guid: user.guid,
tax_exempt: user.tax_exempt?,
run_name: run_name
}
end
def format_add_ons(subscription)
subscription.subscription_add_ons.map { |add_on| {add_on_code:
add_on.add_on_code, quantity: 1, unit_amount_in_cents:
add_on.unit_amount_in_cents} }
end
def line_item_vertex_params(subscription, taxable_attributes)
if subscription.pending_subscription
subscription_add_ons =
format_add_ons(subscription.pending_subscription)
else
subscription_add_ons = format_add_ons(subscription)
end
taxes = subscription_add_ons.find { |add_on| add_on[:add_on_code] ==
TAX_ADDON_CODE }
tax_amount = taxes.nil? ? 0 : taxes[:unit_amount_in_cents]
add_ons_without_tax = subscription_add_ons.reject { |add_on|
add_on[:add_on_code] == TAX_ADDON_CODE }
vertex_params = {address:
{state: taxable_attributes[:state],
zipcode: taxable_attributes[:zip]},
addon_codes: add_ons_without_tax,
tax_exempt: taxable_attributes[:tax_exempt],
tax_amount: tax_amount,
batch_job_line_item: true
}
end
def update_tax(subscription, taxable_attributes)
@line_item = nil
@batch_job_line_item = []
vertex_params = line_item_vertex_params(subscription,
taxable_attributes)
tax_response = VertexCalls.builds_tax_add_on(vertex_params) do |err,
package_tax, package_guid, package_price|
if err
@line_item = BatchJobLineItem.create({status: "VERTEX_ERROR",
user_guid: taxable_attributes[:user_guid],
run_name: taxable_attributes[:run_name],
subscription_uuid: subscription.uuid})
else
@batch_job_line_item << {user_guid: taxable_attributes[:user_guid],
plan_code: subscription.plan_code,
tax_amount: package_tax.to_s,
package_guid: package_guid,
run_name: taxable_attributes[:run_name],
subscription_uuid: subscription.uuid,
package_price: package_price
}
end
end
tax_response=tax_response.try(:deep_symbolize_keys)
line_item_log("user: #{taxable_attributes[:user_guid]}; old_tax:
#{vertex_params[:tax_amount]} new_tax:
#{tax_response[:unit_amount_in_cents]}")
need_to_update = (tax_response[:unit_amount_in_cents] !=
vertex_params[:tax_amount] && @line_item.nil?)
line_item_log("user: #{taxable_attributes[:user_guid]} having the
correct tax") unless need_to_update
if need_to_update
timeframe = subscription.state == 'future' ? 'now' : 'renewal'
updated_add_ons = vertex_params[:addon_codes] + [tax_response]
updated_add_ons.each{ |add_on| add_on.delete_if {|key, value| key
==:geocode}}
is_updated = subscription.update_attributes(:subscription_add_ons =>
updated_add_ons, :timeframe => timeframe)
update_batch_job_line_item(is_updated,@batch_job_line_item,taxable_attributes)
elsif (tax_response[:unit_amount_in_cents] ==
vertex_params[:tax_amount]) && @line_item.nil?
@batch_job_line_item.each do |line_item|
line_item.merge!({status: "PROCESSED"})
BatchJobLineItem.create(line_item)
end if @batch_job_line_item.present?
end
rescue => e
line_item_log("Exception Raised at #{__method__.to_s} : #{e.message}
User: #{taxable_attributes[:user_guid]}")
create_line_item_error("UPDATE_TAX_ERROR",
taxable_attributes[:user_guid], taxable_attributes[:run_name])
end
def
update_batch_job_line_item(is_updated,batch_job_line_item,taxable_attributes)
batch_job_line_item.each do |line_item|
line_item.merge!({status: is_updated ? "PROCESSED": "RECURLY_ERROR"})
BatchJobLineItem.create(line_item)
end if batch_job_line_item.present?
if is_updated
line_item_log("At #{__method__.to_s}: updated taxes to the user:
#{taxable_attributes[:user_guid]}")
else
line_item_log("At #{__method__.to_s}: unable to update taxes user:
#{taxable_attributes[:user_guid]}")
end
end
def will_not_renew?(subscription)
subscription.total_billing_cycles.present? &&
subscription.total_billing_cycles == 1
end
def line_item_log(info)
Rails.logger.info(info)
if !['production','beta'].include?(Rails.env)
line_item_logger ||= Logger.new(STDOUT)
line_item_logger.info(info)
end
end
end
…On Thu, Jan 26, 2017 at 12:30 PM, Benjamin Eckel ***@***.***> wrote:
@akannur <https://github.com/akannur> This error is coming from the ruby
client so this issue may in this repo: https://github.com/recurly/
recurly-client-ruby
I'd need to see the code that is causing this to be sure, but it looks
like it's maybe getting some kind of HTML page and expecting XML. Could you
show the code which generated this error?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#318 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFta0luHhKBwgaHV2qPvMA6wsulFSTOBks5rWPRzgaJpZM4Lu1HZ>
.
--
Anup Kumar Kannur
Software Developer
Direct: +17204923130 | Office: +13034594310
9155 E Nichols Ave Suite,
Centennial, CO 80112
www.qwinix.io
--
DISCLAIMER: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you have received this email in error,
please notify the sender and delete this email from your system. Thank you.
|
@akannur I'm a bit confused as to where the problem is in this code. Could you provide some code to help me reproduce the problem? Or maybe you can point out where in this code the problem is occurring. |
@akannur If it's something you aren't able to reproduce, it might be a hiccup 502 error that cloudflare is giving you. I think because cloudflare is sending back html and the xml parser is exploding it is obscuring the fact that this is a 502 error. If this turns out to be the case I will change the ruby client to have a clearer error message. |
Sure when can you do that?
…On Thu, Jan 26, 2017 at 1:47 PM, Benjamin Eckel ***@***.***> wrote:
@akannur <https://github.com/akannur> If it's something you aren't able
to reproduce, it might be a hiccup error that cloudflare is giving you. I
think because cloudflare is sending back html and the xml parser is
exploding it is obscuring the fact that this is a 502 error.
If this turns out to be the case I will change the ruby client to have a
clearer error message.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#318 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFta0t78T-E3M5MBkvpVgDxQaO4vBtH7ks5rWQZ2gaJpZM4Lu1HZ>
.
--
Anup Kumar Kannur
Software Developer
Direct: +17204923130 | Office: +13034594310
9155 E Nichols Ave Suite,
Centennial, CO 80112
www.qwinix.io
--
DISCLAIMER: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you have received this email in error,
please notify the sender and delete this email from your system. Thank you.
|
@akannur I'm still not certain that it's not another problem. Were you able to reproduce it or does it seem like it was a one off thing? |
Issue is not consistent happens once in a while
…On Thu, Jan 26, 2017 at 4:43 PM, Benjamin Eckel ***@***.***> wrote:
@akannur <https://github.com/akannur> I'm still not certain that it's not
another problem. Were you able to reproduce it or does it seem like it was
a one off thing?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#318 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFta0mbQBQ24B-S5j6pbyO0BFjY1Is6qks5rWS--gaJpZM4Lu1HZ>
.
--
Anup Kumar Kannur
Software Developer
Direct: +17204923130 | Office: +13034594310
9155 E Nichols Ave Suite,
Centennial, CO 80112
www.qwinix.io
--
DISCLAIMER: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you have received this email in error,
please notify the sender and delete this email from your system. Thank you.
|
@akannur I'm closing this as it belongs in the ruby client's repo. You can follow along here now: recurly/recurly-client-ruby#296 |
Not able to merge your PR, and is it fixed now in gem ? Its happening in
PROD for us.
…On Fri, Jan 27, 2017 at 11:14 AM, Benjamin Eckel ***@***.***> wrote:
Closed #318 <#318>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#318 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFta0mlGvkU4dNVib4XNG-D6JTzsUM9Fks5rWjP9gaJpZM4Lu1HZ>
.
--
Anup Kumar Kannur
Software Developer
Direct: +17204923130 | Office: +13034594310
9155 E Nichols Ave Suite,
Centennial, CO 80112
www.qwinix.io
--
DISCLAIMER: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you have received this email in error,
please notify the sender and delete this email from your system. Thank you.
|
@akannur I'm going to do a release today of version |
Thanks a lot.
…On Fri, Jan 27, 2017 at 11:48 AM, Benjamin Eckel ***@***.***> wrote:
@akannur <https://github.com/akannur> I'm going to do a release today of
version 2.7.6 which will include this change.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#318 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFta0tdavn4lqKl4aEHgRsRvHFDTkR6uks5rWjvtgaJpZM4Lu1HZ>
.
--
Anup Kumar Kannur
Software Developer
Direct: +17204923130 | Office: +13034594310
9155 E Nichols Ave Suite,
Centennial, CO 80112
www.qwinix.io
--
DISCLAIMER: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you have received this email in error,
please notify the sender and delete this email from your system. Thank you.
|
...
Missing end tag for 'meta' ﴾got "head"﴿
Line: 27
Position: 1590
Last 80 unconsumed characters:
Line: 27
Position: 1590
Last 80 unconsumed characters:
/opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/xml/rexml.rb:7:in
new' /opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/xml/rexml.rb:7:in
initialize'/opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/xml.rb:55:in
initialize' /opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/api/errors.rb:49:in
new'/opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/api/errors.rb:49:in
xml' /opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/api/errors.rb:34:in
description'/opt/app/ums/shared/bundle/ruby/1.9.1/gems/recurly‐2.7.3/lib/recurly/api/errors.rb:19:in
to_s' /opt/app/ums/releases/20161215140922/lib/tasks/batch_job_line_item.rake:39:in
message'/opt/app/ums/releases/20161215140922/lib/tasks/batch_job_line_item.rake:39:in
rescue in block ﴾4 levels﴿ in <top ﴾required﴿>' /opt/app/ums/releases/20161215140922/lib/tasks/batch_job_line_item.rake:16:in
block ﴾4 levelsThe text was updated successfully, but these errors were encountered: