Skip to content

fix(input): reject missing values for ordinary string parameters - #8216

Open
Stardust0831 wants to merge 1 commit into
deepmodeling:developfrom
Stardust0831:fix/input-missing-string-values
Open

Stardust0831 wants to merge 1 commit into
deepmodeling:developfrom
Stardust0831:fix/input-missing-string-values

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

What's changed?

A supplied string parameter with no value, such as a bare stru_file, can reach an unchecked first-token access; at EOF without a newline it can instead be silently ignored. Ordinary string readers now register the shared scalar contract, requiring exactly one token before their read callbacks run. Invalid input reports the parameter, expected value and manual link:

Invalid INPUT parameter 'stru_file': supplied ''. Expected one String.
See https://abacus.deepmodeling.com/en/latest/advanced/input_files/input-main.html#stru-file

The change applies through read_sync_string, including stru_file, kpoint_file, suffix and dft_functional. It also rejects extra tokens such as stru_file STRU extra, which were previously ignored. Omitted parameters retain their defaults; custom readers permitting empty values or multiple tokens keep their existing grammar.

Linked Issue

Addresses the missing-value follow-up in #8192, continuing #7719.

Merge #8215 first so duplicate parameters at EOF use the shared MPI error broadcast.

Unit Tests and/or Case Tests for my changes

Passed: 44 reader/item tests, 30 help tests, three documentation-generator tests, 12 executable input checks, and serial/four-process Si SCF calculations. Coverage includes EOF, comments, extra tokens, explicit paths, omitted defaults, legal empty values and generated INPUT round trips.

The combined changes with #8215 also passed four-process reader checks for duplicate, missing and valid suffix input at EOF without a final newline; all four processes reached shutdown in each case.

Build and test commands

SERIAL_BUILD and MPI_BUILD are Release builds with MPI disabled/enabled respectively. Both use GCC 13.4, OpenMP enabled, LCAO/ELPA/FLOAT_FFTW disabled, and OMP_NUM_THREADS=1 at runtime. Executables report v3.11.0-beta11.

cmake --build "$SERIAL_BUILD" --target MODULE_IO_input_domain_reader \
  MODULE_IO_read_item_serial MODULE_IO_read_input_serial abacus_pw_omp -j 8
ctest --test-dir "$SERIAL_BUILD" -V \
  -R '^MODULE_IO_(input_domain_reader|read_item_serial|read_input_serial)$'

cmake --build "$MPI_BUILD" --target abacus_pw_para MODULE_IO_input_help_test -j 8
ctest --test-dir "$MPI_BUILD" -V -R '^MODULE_IO_input_help_test$'
python3 -m unittest discover -s docs -p test_generate_input_main.py -v

"$SERIAL_BUILD/abacus_pw_omp" --version
"$SERIAL_BUILD/abacus_pw_omp" -h stru_file
# From each prepared INPUT case directory:
"$SERIAL_BUILD/abacus_pw_omp" --check-input
mpirun -np 4 "$MPI_BUILD/abacus_pw_para"

Successful MPI --check-input has an existing finalization issue, so MPI executable checks use normal execution. Governance and whitespace checks passed.

Governance Notes

The shared reader registration supplies the scalar contract, and the developer guide describes it. YAML export and reference generation succeeded for 590 parameters. The change is confined to input validation and its tests; no calculation modules are modified. No exceptions requested.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Static review at 294c777. No builds or runtime tests were run. One nonblocking integration suggestion follows.

Comment thread source/source_io/module_parameter/read_input_tool.h
@Stardust0831 Stardust0831 added the Input&Output Suitable for coders without knowing too many DFT details label Oct 24, 2026

@AsTonyshment AsTonyshment left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. CC: @mohanchen merge PR #8215 first, thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Input&Output Suitable for coders without knowing too many DFT details

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants