metanorma / pubid-iso

Implementation of ISO pubid
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

(URGENT) pubid-iso 0.4.0 fails to parse "ISO/IEC 23008-1/WD Amd 1" identifier #215

Closed ronaldtse closed 1 year ago

ronaldtse commented 1 year ago

@mico the new version of pubid-iso fails to parse "ISO/IEC 23008-1/WD Amd 1" identifier of the doc https://www.iso.org/standard/82727.html

Pubid::Iso::Identifier.parse("ISO/IEC 23008-1/WD Amd 1")
TypeError: can't create instance of singleton class
from /Users/andrej/.rvm/gems/ruby-3.0.0/gems/pubid-iso-0.4.0/lib/pubid/iso/identifier.rb:20:in `new'

The previus version of this gem parses the ID without error.

Originally posted by @andrew2net in https://github.com/metanorma/pubid-iso/issues/207#issuecomment-1414546577

mico commented 1 year ago

Seems you did something different instead of: require 'pubid-iso' so you don't have all needed files included. If you do so, you will get another error:

2.6.6 :001 > require 'pubid-iso'
 => true
2.6.6 :002 > Pubid::Iso::Identifier
 => Pubid::Iso::Identifier
2.6.6 :003 > Pubid::Iso::Identifier.parse("ISO/IEC 23008-1/WD Amd 1")
Traceback (most recent call last):
       16: from /Users/mico/.rvm/rubies/ruby-2.6.6/bin/irb:23:in `<top (required)>'
       15: from /Users/mico/.rvm/rubies/ruby-2.6.6/bin/irb:23:in `load'
       14: from /Users/mico/.rvm/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
       13: from (irb):3
       12: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:40:in `parse'
       11: from /Users/mico/.rvm/gems/ruby-2.6.6/gems/pubid-core-1.5.1/lib/pubid/core/identifier.rb:77:in `parse'
       10: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier/base.rb:182:in `transform'
        9: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier/base.rb:152:in `transform_supplements'
        8: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier/base.rb:152:in `map'
        7: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier/base.rb:153:in `block in transform_supplements'
        6: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:7:in `create'
        5: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:18:in `resolve_identifier'
        4: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:18:in `each'
        3: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:20:in `block in resolve_identifier'
        2: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier.rb:20:in `new'
        1: from /Users/mico/Projects/pubid-iso/lib/pubid/iso/identifier/amendment.rb:30:in `initialize'
Pubid::Iso::Errors::SupplementWithoutYearOrStageError (Cannot apply supplement to document without base identifier edition year or stage)

Pubid::Iso::Errors::SupplementWithoutYearOrStageError was introduced since 0.2.1, so this identifier will always raise this error until you define a year for base identifier.

ronaldtse commented 1 year ago

This is a good point. I remember that this is somewhat problematic...

The identifier "ISO/IEC 23008-1/WD Amd 1" did exist at one point -- it was an Amendment created on a base document that hasn't been published.

Now the base document has just been published (in 2023), so the identifier is now: "ISO/IEC 23008-1:2023/WD Amd 1"

Screen Shot 2023-02-04 at 3 22 28 PM

So I might have been wrong to insist that SupplementWithoutYearOrStageError is always raised. However, it remains that an amendment identifier with a base identifier that lacks the "edition year" is not quite valid.

@mico , if we allow this identifier to be created/used, what are the problems we will face?

Here are some that I can think of:

mico commented 1 year ago

@mico , if we allow this identifier to be created/used, what are the problems we will face?

Here are some that I can think of:

  • URN cannot be created because there is no edition year on base
  • anything else ...?

Event URN creation is not problematic, we just don't have base identifier's year there.

mico commented 1 year ago

@ronaldtse https://standards.ieee.org/ieee/1672-2006_Cor_1/4460/ (IEEE 1672-2006/Cor 1-2008) Is it another example of ISO identifier with supplement but without base identifier edition year provided?